9 #ifndef __LOGOG_SOCKET_HPP_ 
   10 #define __LOGOG_SOCKET_HPP_ 
   12 #ifdef LOGOG_FLAVOR_WINDOWS 
   13 #pragma comment(lib, "wsock32.lib") 
   26         static bool bInitialized = 
false;
 
   30 #ifdef LOGOG_FLAVOR_WINDOWS 
   31             WORD wVersionRequested;
 
   34             wVersionRequested = MAKEWORD( 2, 2 );
 
   36             err = WSAStartup( wVersionRequested, &wsaData );
 
   40 #ifdef LOGOG_INTERNAL_DEBUGGING 
   41                 LOGOG_COUT << 
_LG(
"WSAStartup failed with error: ") <<  err << endl;
 
   56 #ifdef LOGOG_FLAVOR_WINDOWS 
   64         int type = SOCK_STREAM,
 
   75 #ifdef LOGOG_FLAVOR_WINDOWS 
   78 #ifdef LOGOG_FLAVOR_POSIX 
   84     virtual int Create( 
int type,
 
   87         char myname[MAXHOSTNAME+1];
 
   89         struct sockaddr_in sa;
 
   92         memset( &sa, 0, 
sizeof( 
struct sockaddr_in ) ); 
 
   93         gethostname( myname, MAXHOSTNAME );         
 
   94         hp= gethostbyname( myname );                
 
   99         sa.sin_family= hp->h_addrtype;              
 
  100         sa.sin_port= (u_short)htons( (u_short)port );                
 
  102         if (( 
m_Socket = socket( AF_INET, type, 0 ) ) < 0 ) 
 
  105         if ( bind( 
m_Socket,  (
struct sockaddr*) &sa, 
sizeof( 
struct sockaddr_in ) ) < 0 )
 
  121 #ifdef LOGOG_FLAVOR_POSIX 
  123         flags = socket_fcntl( 
m_Socket, F_GETFL, 0 );
 
  125         err = socket_fcntl( 
m_Socket, F_SETFL, flags );
 
  128 #ifdef LOGOG_FLAVOR_WINDOWS 
  131         err = ioctlsocket( 
m_Socket, FIONBIO, &parg );
 
  150 #endif // __LOGOG_CHECKPOINT_HPP_ 
[Thread] 
Definition: api.hpp:8
 
Definition: target.hpp:16
 
#define LOGOG_STRING
Definition: string.hpp:113
 
int m_Socket
Definition: socket.hpp:139
 
int m_nType
Definition: socket.hpp:140
 
virtual int Output(const LOGOG_STRING &output)=0
 
Socket(int type=SOCK_STREAM, int port=LOGOG_DEFAULT_PORT)
Definition: socket.hpp:63
 
virtual int SetNonBlocking()
Definition: socket.hpp:117
 
virtual void Close()
Definition: socket.hpp:73
 
#define _LG(x)
Definition: string.hpp:53
 
Definition: socket.hpp:144
 
Definition: socket.hpp:21
 
static const int MAXHOSTNAME
Definition: socket.hpp:61
 
static void Shutdown()
Definition: socket.hpp:54
 
int m_nPort
Definition: socket.hpp:141
 
static int Initialize()
Definition: socket.hpp:24