X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=simgear%2Fio%2Fraw_socket.hxx;h=833b75c3ba3d8d6c4d929f34eef744478ed0546e;hb=adb7db9229db1d869b254ac18f1471bed464c508;hp=4eb304488847c9bfef2280db90f127b22ac87e44;hpb=5208750cdb34ed98411a2104963965b08fb72a47;p=simgear.git diff --git a/simgear/io/raw_socket.hxx b/simgear/io/raw_socket.hxx index 4eb30448..833b75c3 100644 --- a/simgear/io/raw_socket.hxx +++ b/simgear/io/raw_socket.hxx @@ -17,18 +17,21 @@ You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ #ifndef SG_IO_SOCKET_HXX #define SG_IO_SOCKET_HXX -#include +//#include -#if defined(__APPLE__) || defined(__FreeBSD__) -# include -#endif +//#if defined(__APPLE__) || defined(__FreeBSD__) +//# include +//#endif +struct sockaddr_in; +struct sockaddr; + namespace simgear { @@ -37,32 +40,31 @@ namespace simgear */ class IPAddress { - /* DANGER!!! This MUST match 'struct sockaddr_in' exactly! */ -#if defined(__APPLE__) || defined(__FreeBSD__) - __uint8_t sin_len; - __uint8_t sin_family; - in_port_t sin_port; - in_addr_t sin_addr; - char sin_zero[8]; -#else - short sin_family ; - unsigned short sin_port ; - unsigned int sin_addr ; - char sin_zero [ 8 ] ; -#endif - + mutable struct sockaddr_in* addr; public: - IPAddress () {} + IPAddress () : addr(0) {} IPAddress ( const char* host, int port ) ; + ~IPAddress(); + + static bool lookupNonblocking(const char* host, IPAddress& addr); + + IPAddress( const IPAddress& other ); + const IPAddress& operator=(const IPAddress& other); + bool isValid () const; void set ( const char* host, int port ) ; const char* getHost () const ; unsigned int getPort() const ; + void setPort(int port); + unsigned int getIP () const ; unsigned int getFamily () const ; static const char* getLocalHost () ; bool getBroadcast () const ; + + unsigned int getAddrLen() const; + sockaddr* getAddr() const; }; @@ -72,7 +74,7 @@ public: class Socket { int handle ; - + public: Socket () ; @@ -89,6 +91,7 @@ public: int listen ( int backlog ) ; int accept ( IPAddress* addr ) ; int connect ( const char* host, int port ) ; + int connect ( IPAddress* addr ) ; int send ( const void * buffer, int size, int flags = 0 ) ; int sendto ( const void * buffer, int size, int flags, const IPAddress* to ) ; int recv ( void * buffer, int size, int flags = 0 ) ;