#ifndef SG_IO_SOCKET_HXX
#define SG_IO_SOCKET_HXX
-#include <errno.h>
+//#include <errno.h>
-#if defined(__APPLE__) || defined(__FreeBSD__)
-# include <netinet/in.h>
-#endif
+//#if defined(__APPLE__) || defined(__FreeBSD__)
+//# include <netinet/in.h>
+//#endif
+struct sockaddr_in;
+struct sockaddr;
+
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
-
+ struct sockaddr_in* addr;
public:
- IPAddress () {}
+ IPAddress () : addr(0) {}
IPAddress ( const char* host, int port ) ;
-
+ ~IPAddress();
+
void set ( const char* host, int port ) ;
const char* getHost () const ;
unsigned int getPort() const ;
static const char* getLocalHost () ;
bool getBroadcast () const ;
+
+ unsigned int getAddrLen() const;
+ sockaddr* getAddr() const;
};
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 ) ;