Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Class Members | File Members

Socket Class Reference

Inheritance diagram for Socket:

Stream SslSocket List of all members.

Public Member Functions

Socket accept (MYSERVER_SOCKADDR *, int *)
int bind (MYSERVER_SOCKADDR *, int)
virtual u_long bytesToRead ()
virtual int closesocket ()
int connect (const char *host, u_short port)
virtual int connect (MYSERVER_SOCKADDR *, int)
virtual int dataOnRead (int sec=0, int usec=500)
SocketHandle getHandle ()
SocketgetServerSocket ()
int getsockname (MYSERVER_SOCKADDR *, int *)
u_long getThrottling ()
int ioctlsocket (long, unsigned long *)
int listen (int)
int operator= (Socket)
int operator== (Socket)
virtual int read (char *buffer, u_long len, u_long *nbr)
virtual int recv (char *, int, int)
virtual int recv (char *, int, int, u_long)
int send (const char *, int, int)
int setHandle (SocketHandle)
int setNonBlocking (int)
void setServerSocket (Socket *)
int setsockopt (int, int, const char *, int)
void setThrottling (u_long)
virtual int shutdown (int how)
 Socket (SocketHandle)
 Socket (Socket *)
 Socket ()
int socket (int, int, int)
virtual int write (const char *buffer, u_long len, u_long *nbw)

Static Public Member Functions

MYSERVER_HOSTENTgethostbyaddr (char *addr, int len, int type)
MYSERVER_HOSTENTgethostbyname (const char *)
int gethostname (char *, int)
int getLocalIPsList (string &)
void stopBlockingOperations (bool)

Protected Member Functions

virtual int rawSend (const char *buffer, int len, int flags)

Protected Attributes

SocketserverSocket
SocketHandle socketHandle
u_long throttlingRate

Static Protected Attributes

bool denyBlockingOperations = false

Constructor & Destructor Documentation

Socket::Socket  ) 
 

Constructor of the class.

Socket::Socket Socket socket  ) 
 

Set the socket handle.

Socket::Socket SocketHandle  handle  ) 
 

Set the socket handle.


Member Function Documentation

Socket Socket::accept MYSERVER_SOCKADDR sa,
int *  sockaddrlen
 

Accept a new connection.

int Socket::bind MYSERVER_SOCKADDR sa,
int  namelen
 

Bind the port to the socket.

u_long Socket::bytesToRead  )  [virtual]
 

Returns the number of bytes waiting to be read.

Reimplemented in SslSocket.

int Socket::closesocket  )  [virtual]
 

Close the socket.

Reimplemented in SslSocket.

int Socket::connect const char *  host,
u_short  port
 

Connect to the specified host:port. Returns zero on success.

int Socket::connect MYSERVER_SOCKADDR sa,
int  na
[virtual]
 

Connect the socket.

Reimplemented in SslSocket.

int Socket::dataOnRead int  sec = 0,
int  usec = 500
[virtual]
 

Check if there is data ready to be read. Returns 1 if there is data to read, 0 if not.

Reimplemented in SslSocket.

SocketHandle Socket::getHandle  ) 
 

Returns the socket handle

MYSERVER_HOSTENT * Socket::gethostbyaddr char *  addr,
int  len,
int  type
[static]
 

Returns an host by its address.

MYSERVER_HOSTENT * Socket::gethostbyname const char *  hostname  )  [static]
 

Returns an host by its name

int Socket::gethostname char *  name,
int  namelen
[static]
 

Returns the hostname.

int Socket::getLocalIPsList string &  out  )  [static]
 

Fill the out string with a list of the local IPs. Returns 0 on success.

Socket * Socket::getServerSocket  ) 
 

Returns the server socket.

int Socket::getsockname MYSERVER_SOCKADDR ad,
int *  namelen
 

Returns the sockname.

u_long Socket::getThrottling  ) 
 

Return the throttling rate(bytes/second) used by the socket. A return value of zero means that no throttling is used.

int Socket::ioctlsocket long  cmd,
unsigned long *  argp
 

Function used to control the socket.

int Socket::listen int  max  ) 
 

Listen for other connections.

int Socket::operator= Socket  s  ) 
 

Set the socket using the = operator

int Socket::operator== Socket  s  ) 
 

Check if the two sockets have the same handle descriptor

int Socket::rawSend const char *  buffer,
int  len,
int  flags
[protected, virtual]
 

Send data over the socket. Return -1 on error. This routine is accessible only from the Socket class.

Reimplemented in SslSocket.

int Socket::read char *  buffer,
u_long  len,
u_long *  nbr
[virtual]
 

Inherithed from Stream.

Reimplemented from Stream.

int Socket::recv char *  buffer,
int  len,
int  flags
[virtual]
 

Receive data from the socket. Returns -1 on errors.

Reimplemented in SslSocket.

int Socket::recv char *  buffer,
int  len,
int  flags,
u_long  timeout
[virtual]
 

Receive data from the socket.

int Socket::send const char *  buffer,
int  len,
int  flags
 

Send data over the socket. Returns -1 on error. Returns the number of bytes sent on success. If a throttling rate is specified, send will use it.

int Socket::setHandle SocketHandle  h  ) 
 

Set the handle for the socket

int Socket::setNonBlocking int  non_blocking  ) 
 

Pass a nonzero value to set the socket to be nonblocking.

void Socket::setServerSocket Socket sock  ) 
 

Set the socket used by the server.

int Socket::setsockopt int  level,
int  optname,
const char *  optval,
int  optlen
 

Set socket options.

void Socket::setThrottling u_long  tr  ) 
 

Set the throttling rate(bytes/second) for the socket. Use a zero rate to disable throttling.

int Socket::shutdown int  how  )  [virtual]
 

Shutdown the socket.

Reimplemented in SslSocket.

int Socket::socket int  af,
int  type,
int  protocol
 

Create the socket.

void Socket::stopBlockingOperations bool  value  )  [static]
 

Set this to true to stop any operation that can block sockets.

int Socket::write const char *  buffer,
u_long  len,
u_long *  nbw
[virtual]
 

Inherited from Stream. Return values are equals to send.

Reimplemented from Stream.


Member Data Documentation

bool Socket::denyBlockingOperations = false [static, protected]
 

Stop the sockets system.

Socket* Socket::serverSocket [protected]
 

Pointer to the socket that has accepted this connection.

SocketHandle Socket::socketHandle [protected]
 

u_long Socket::throttlingRate [protected]
 

Send throttling rate.


Generated on Thu May 1 12:41:05 2008 for MyServer by  doxygen 1.3.9.1