X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=simgear%2Fio%2Fraw_socket.hxx;h=9450e9eb8729cefe97caeefbfc445172e3a3513d;hb=1cb9a79fd48ce6151f6a2cf8d07ef23e002a81b1;hp=f68ff105b35cc9c2b9a97d47ddb768da0dc80c65;hpb=792ffa2d264369fe998c7b102e6e0a097a8c20f9;p=simgear.git diff --git a/simgear/io/raw_socket.hxx b/simgear/io/raw_socket.hxx index f68ff105..9450e9eb 100644 --- a/simgear/io/raw_socket.hxx +++ b/simgear/io/raw_socket.hxx @@ -23,12 +23,15 @@ #ifndef SG_IO_SOCKET_HXX #define SG_IO_SOCKET_HXX -#include +//#include -#if defined(__APPLE__) -# include -#endif +//#if defined(__APPLE__) || defined(__FreeBSD__) +//# include +//#endif +struct sockaddr_in; +struct sockaddr; + namespace simgear { @@ -37,32 +40,30 @@ namespace simgear */ class IPAddress { - /* DANGER!!! This MUST match 'struct sockaddr_in' exactly! */ -#ifdef __APPLE__ - __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); 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 +73,7 @@ public: class Socket { int handle ; - + public: Socket () ; @@ -89,6 +90,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 ) ;