gxSocket Class


Topics:

Overview
Conditional Directives
Constants
Type Definitions
Enumerations
Functions


Overview

The gxSocket class is an object-oriented Winsock/BSD wrapper used to create TCP/IP sockets on WIN32 and UNIX platforms. The gxSocket class supports stream sockets and datagram sockets and includes several low-level functions needed by derived classes to establish communication end-points and transfer data. Raw sockets are supported under UNIX and Windows 2000 with limited raw socket support for Windows 95/98/ME/NT.


Conditional Directives

__WIN32__ - Conditional directive required for all WIN32 platforms

__UNIX__ - Conditional directive required for all UNIX variants.

__HPUX__ - Conditional directive required for all HPUX platforms.

__LINUX__ - Conditional directive required for all Linux platforms.

__SOLARIS__ - Conditional directive required for all Solaris platforms.

__BSD_UNIX__ - Conditional directive used only if BSD include files are required. This directive is not required by any of the UNIX platforms supported by gxSocket version 4.


Constants

const unsigned gxsBUF_SIZE     =  1024; // Fixed string buffer length
const unsigned gxsMAX_NAME_LEN =  256;  // Maximum string name length
const unsigned gxsRX_BUF_SIZE  =  4096; // Default receive buffer size
const unsigned gxsTX_BUF_SIZE  =  4096; // Default transmit buffer size
  
// IANA assigned port number for database block sockets
const int gxsDATA_PORT = 2073;


Type Definitions

gxsAddressFamily - Type definition used to represent the address family to which a socket belongs.

gxsProtocolFamily - Type definition used to represent the protocol family to which a socket belongs.

gxsSocket_t - Type used to ID sockets.

gxsPort_t - Type used for port numbers.

gxsSocketAddress - Type used to for a socket Internet address structures.

gxsServent - Type definition used for service name and protocol information structures.

gxsHostNameInfo - Type definition used for host name information structures.

gxsInternetAddress - Type definition used for Internet address structures.


Enumerations

enum gxsSocketError {    // gxSocket exception codes
  gxSOCKET_NO_ERROR = 0,       // No socket errors reported
  gxSOCKET_INVALID_ERROR_CODE, // Invalid socket error code

  // Socket error codes
  gxSOCKET_ACCEPT_ERROR,         // Error accepting remote socket
  gxSOCKET_BIND_ERROR,           // Could not bind socket
  gxSOCKET_BUFOVER_ERROR,        // Buffer overflow
  gxSOCKET_CONNECT_ERROR,        // Could not connect socket
  gxSOCKET_FILESYSTEM_ERROR,     // A file system error occurred
  gxSOCKET_GETOPTION_ERROR,      // Error getting socket option
  gxSOCKET_HOSTNAME_ERROR,       // Could not resolve hostname
  gxSOCKET_INIT_ERROR,           // Initialization error
  gxSOCKET_LISTEN_ERROR,         // Listen error
  gxSOCKET_PEERNAME_ERROR,       // Get peer name error
  gxSOCKET_PROTOCOL_ERROR,       // Unknown protocol requested
  gxSOCKET_RECEIVE_ERROR,        // Receive error
  gxSOCKET_REQUEST_TIMEOUT,      // Request timed out
  gxSOCKET_SERVICE_ERROR,        // Unknown service requested
  gxSOCKET_SETOPTION_ERROR,      // Error setting socket option
  gxSOCKET_SOCKNAME_ERROR,       // Get socket name error
  gxSOCKET_SOCKETTYPE_ERROR,     // Unknown socket type requested
  gxSOCKET_TRANSMIT_ERROR,       // Transmit error

  // WIN32 WinSock Error Codes (Transparent to UNIX applications)
  gxSOCKET_WINSOCKCLEANUP_ERROR, // WSACleanup operation failed
  gxSOCKET_WINSOCKEINVAL_ERROR,  // Version not supported by DLL
  gxSOCKET_WINSOCKINIT_ERROR,    // Could not initialize Winsock
  gxSOCKET_WINSOCKNETWORK_ERROR, // Network subsystem is not ready
  gxSOCKET_WINSOCKVERSION_ERROR, // Requested version not supported
  
  // Exception codes added to handle variable block errors
  gxSOCKET_BLOCKACK_ERROR,    // Database block acknowledgment error
  gxSOCKET_BLOCKHEADER_ERROR, // Bad variable block header
  gxSOCKET_BLOCKSIZE_ERROR,   // Bad variable block size
  gxSOCKET_BLOCKSYNC_ERROR    // Variable block synchronization error
};

enum gxsSocketLibraryVersion {
  // Platform specific library version constants

  // WIN32 supported WSA versions. NOTE: The WSA constants have no
  // meaning in UNIX implementations but will work transparently in
  // all UNIX applications.
  gxSOCKET_WSAVER_ONEZERO, // Testing purposes only
  gxSOCKET_WSAVER_ONEONE,  // Windows 95A/B/C, 98, 98SE, NT4.0 
  gxSOCKET_WSAVER_TWOZERO, // Windows 98, 98SE, 2000 compatible
  gxSOCKET_WSAVER_TWOTWO   // Windows 98SE, 2000 compatible
};

enum gxsServices {
// Enumeration for common port numbers found in the /etc/services file
// on UNIX platforms or the \windows\services file on WIN32 platforms.
// A complete list of all assigned port numbers is maintained by IANA:
// http://www.iana.org
// http://www.iana.org/assignments/port-numbers

  // Common port assignments
  gxSOCKET_ECHO_PORT       = 7,   // Echo port
  gxSOCKET_FTPDATA_PORT    = 20,  // FTP data port
  gxSOCKET_FTP_PORT        = 21,  // tcp ftp port
  gxSOCKET_TELNET_PORT     = 23,  // tcp telnet port
  gxSOCKET_SMTP_PORT       = 25,  // tcp simple mail transfer protocol
  gxSOCKET_TIME_PORT       = 37,  // tcp time server
  gxSOCKET_NAME_PORT       = 42,  // tcp name server
  gxSOCKET_NAMESERVER_PORT = 53,  // tcp domain name server
  gxSOCKET_FINGER_PORT     = 79,  // tcp finger port
  gxSOCKET_HTTP_PORT       = 80,  // tcp http port
  gxSOCKET_POP_PORT        = 109, // tcp postoffice protocol
  gxSOCKET_POP2_PORT       = 109, // tcp postoffice protocol
  gxSOCKET_POP3_PORT       = 110, // tcp postoffice protocol
  gxSOCKET_NNTP_PORT       = 119, // tcp network news transfer protocol

  // 03/19/2001: IANA assigned port number for database block sockets 
  gxSOCKET_DBS_PORT     = 2073, // gx-dbs-port
  gxSOCKET_DEFAULT_PORT = 2073  // Default port assignment if no port is specified
};

enum gxsServerTypes {
  gxSOCKET_STREAM_SERVER,
  gxSOCKET_DATAGRAM_SERVER,
  gxSOCKET_SERIAL_PORT_SERVER,
  gxSOCKET_HTTP_SERVER,
  gxSOCKET_LOCAL_FILE_SYSTEM
};

enum gxClientTypes {
  gxSOCKET_STREAM_CLIENT,
  gxSOCKET_DATAGRAM_CLIENT,
  gxSOCKET_HTTP_CLIENT,
  gxSOCKET_SERIAL_PORT_CLIENT
};


Functions

gxSocket::gxSocket()
gxSocket::~gxSocket()
gxSocket::Accept()
gxSocket::Bind()
gxSocket::BytesMoved()
gxSocket::BytesRead()
gxSocket::Close()
gxSocket::CloseRemoteSocket()
gxSocket::CloseSocket()
gxSocket::Connect()
gxSocket::GetAddressFamily()
gxSocket::GetBoundIPAddress()
gxSocket::GetBoundSocket()
gxSocket::GetBytesMoved()
gxSocket::GetBytesRead()
gxSocket::GetClientInfo()
gxSocket::GetDomainName()
gxSocket::GetHostInformation()
gxSocket::GetHostName()
gxSocket::GetIPAddress()
gxSocket::GetPeerName()
gxSocket::GetPortNumber()
gxSocket::GetProtocolFamily()
gxSocket::GetRemoteAddressFamily()
gxSocket::GetRemoteHostName()
gxSocket::GetRemotePortNumber()
gxSocket::GetRemoteSocket()
gxSocket::GetServByName()
gxSocket::GetServByPort()
gxSocket::GetServiceInformation()
gxSocket::GetSockName()
gxSocket::GetSockOpt()
gxSocket::GetSocket()
gxSocket::GetSocketError()
gxSocket::GetSocketType()
gxSocket::InitSocket()
gxSocket::InitSocketLibrary()
gxSocket::IsBound()
gxSocket::IsConnected()
gxSocket::Listen()
gxSocket::RawRead()
gxSocket::RawReadFrom()
gxSocket::RawRemoteRead()
gxSocket::RawRemoteWrite()
gxSocket::RawWrite()
gxSocket::RawWriteTo()
gxSocket::ReadSelect()
gxSocket::Recv()
gxSocket::RecvFrom()
gxSocket::ReleaseRemoteSocket()
gxSocket::ReleaseSocket()
gxSocket::ReleaseSocketLibrary()
gxSocket::RemoteRecv()
gxSocket::RemoteSend()
gxSocket::ResetError()
gxSocket::ResetRead()
gxSocket::ResetSocketError()
gxSocket::ResetWrite()
gxSocket::Send()
gxSocket::SendTo()
gxSocket::SetAddressFamily()
gxSocket::SetBytesMoved()
gxSocket::SetBytesRead()
gxSocket::SetPortNumber()
gxSocket::SetProtocolFamily()
gxSocket::SetRemoteSocket()
gxSocket::SetSockOpt()
gxSocket::SetSocket()
gxSocket::SetSocketError()
gxSocket::SetSocketType()
gxSocket::ShutDown()
gxSocket::ShutDownRemoteSocket()
gxSocket::ShutDownSocket()
gxSocket::Socket()
gxSocket::SocketExceptionMessage()

gxSocket::gxSocket() - Socket constructor that performs no initialization other then setting default values for the socket data members.

gxSocket::gxSocket(gxsSocket_t st, gxsPort_t port, char *hostname = 0) - Socket constructor used to initialize the socket according to the socket type: SOCK_STREAM or SOCK_DGRAM. All ports below 1024 are reserved. A hostname name should only be specified for client sockets.

gxSocket::gxSocket(gxsAddressFamily af, gxsSocket_t st, gxsProtocolFamily pf, int port, char *hostname = 0) - Socket constructor used to initialize the socket according to the address family, socket type, and protocol family. All ports below 1024 are reserved. A hostname name should only be specified for client sockets.

gxSocket::gxSocket(const gxSocket &ob) - Private copy constructor used to disallow copying.

void gxSocket::operator=(const gxSocket &ob) - Private assignment operator used to disallow assignment.

virtual gxSocket::~gxSocket() - Class destructor used to automatically close an open socket when a gxSocket object is deleted.

gxsSocket_t gxSocket::Accept() - Public member function used to accept a connect from a remote socket. An Accept() call blocks the server until the a client requests service. Returns a valid socket descriptor or -1 if an error occurs.

int gxSocket::Bind() - Public member function used to bind the socket to a name so that other processes can reference it and allow this socket to receive messages. Returns -1 if an error occurs.

int gxSocket::BytesMoved() - Public member function that return the total number of bytes moved following a write operation.

int gxSocket::BytesRead() - Public member function that return the total number of bytes read following a read operation.

void gxSocket::Close() - Public member function used to close any and un-initialize any bound sockets.

void gxSocket::Close(gxsSocket_t &s) - Public member function used to close the specified socket.

void gxSocket::CloseRemoteSocket() - Public member function used to close the client socket.

void gxSocket::CloseSocket() - Public member function used to close the server side socket.

int gxSocket::Connect() - Public member function used to connect the socket to a client or server. On the client side a connect call is used to initiate a connection. Returns -1 if an error occurs.

gxsAddressFamily gxSocket::GetAddressFamily() - Public member function used to retrieve the current address family.

int gxSocket::GetBoundIPAddress(char *sbuf) - Public member function that passes back the local or server IP address in the "sbuf" variable. A memory buffer equal to gxsMAX_NAME_LEN must be pre-allocated prior to using this function. Return -1 if an error occurs.

gxsSocket_t gxSocket::GetBoundSocket() - Public member function used to retrieve the currently bound socket.

int *gxSocket::GetBytesMoved() - Public member function that returns the total number of bytes written.

int *gxSocket::GetBytesRead() - Public member function that returns the total number of bytes read.

void gxSocket::GetClientInfo(char *client_name, int &r_port) - Public member function used to get the client's host name and port number. A memory buffer equal to gxsMAX_NAME_LEN must be pre-allocated prior to using this function.

int gxSocket::GetDomainName(char *sbuf) - Public member function that passes back the domain name of this machine in the "sbuf" variable. A memory buffer equal to gxsMAX_NAME_LEN must be pre-allocated prior to using this function. Return -1 if an error occurs.

gxsHostNameInfo *gxSocket::GetHostInformation(char *hostname) - Public member function used to obtain hostname information about a specified host. The source of this information is dependent on the calling function's platform configuration which should be a DNS, local host table, and/or NIS database. Returns a pointer to a gxsHostNameInfo data structure if information is available or a null value if the hostname cannot be found. NOTE: The calling function must free the memory allocated for gxsHostNameInfo data structure upon each successful return.

int gxSocket::GetHostName(char *sbuf) - Public member function that passes back the host name of this machine in the "sbuf" variable. A memory buffer equal to gxsMAX_NAME_LEN must be pre-allocated prior to using this function. Return -1 if an error occurs.

int gxSocket::GetIPAddress(char *sbuf) - Public member function that passes back the IP Address of this machine in the "sbuf" variable. A memory buffer equal to gxsMAX_NAME_LEN must be pre-allocated prior to using this function. Return -1 if an error occurs.

int gxSocket::GetPeerName(gxsSocket_t s, gxsSocketAddress *sa) - Public member function used to retrieve the current name of the specified socket descriptor. Returns -1 if an error occurs.

int gxSocket::GetPeerName() - Public member function used to retrieve the current name for the remote socket descriptor. Returns -1 if an error occurs.

int gxSocket::GetPortNumber() - Public member function that returns port number actually set by the system. Use this function after a call to the gxSocket::GetSockName() function.

gxsProtocolFamily gxSocket::GetProtocolFamily() - Public member function used to retrieve the current protocol family.

gxsAddressFamily gxSocket::GetRemoteAddressFamily() - Public member function used to retrieve the current address family of the remote socket

int gxSocket::GetRemoteHostName(char *sbuf) - Public member function that passes back the client host name client in the "sbuf" variable. A memory buffer equal to gxsMAX_NAME_LEN must be pre-allocated prior to using this function. Return -1 if an error occurs.

int gxSocket::GetRemotePortNumber() - Public member function that returns the port number of the client socket.

gxsSocket_t gxSocket::GetRemoteSocket() - Public member function used to retrieve the client side socket.

int gxSocket::GetServByName(char *name, char *protocol = 0) - Public member function used to set service information corresponding to a service name and protocol. Returns -1 if an unknown service or protocol is requested. NOTE: This information is obtained from this machines local services file or from a NIS database. If the "protocol" pointer is null, this function passes back the first service entry that matches the protocol name or alias. Otherwise this function matches both the name and the protocol.

int gxSocket::GetServByPort(int port, char *protocol = 0) - Public member function used to set service information corresponding to a port number and protocol. Returns -1 if an unknown service or protocol is requested. NOTE: This information is obtained from this machines local services file or from a NIS database. If the "protocol" pointer is null, this function passes back the first service entry that matches the port number. Otherwise this function matches both the port and the protocol.

gxsServent *gxSocket::GetServiceInformation(char *name, char *protocol = 0) - Public member function used to obtain service information about a specified name. The source of this information is dependent on the calling function's platform configuration, which should be a local services file, or a NIS database. Returns a pointer to a gxsServent data structure if service information is available or a null value if the service cannot be found. NOTE: The calling function must free the memory allocated for gxsServent data structure upon each successful return. If the "protocol" pointer is null, this function passes back the first service entry that matches the protocol name or alias. Otherwise this function matches both the name and the protocol.

gxsServent *gxSocket::GetServiceInformation(int port, char *protocol = 0) - Public member function used to obtain service information about a specified port. The source of this information is dependent on the calling function's platform configuration, which should be a local services file, or a NIS database. Returns a pointer to a gxsServent data structure if service information is available or a null value if the service cannot be found. NOTE: The calling function must free the memory allocated for gxsServent data structure upon each successful return. If the "protocol" pointer is null, this function passes back the first service entry that matches the port number. Otherwise this function matches both the port and the protocol.

int gxSocket::GetSockName(gxsSocket_t s, gxsSocketAddress *sa) - Public member function used to retrieves the current name for the specified socket descriptor. It is used on a bound and/or connected socket and returns the local association. This function is especially useful when a connect call has been made without doing a bind first in which case this function provides the only means by which you can determine the local association which has been set by the system. Returns -1 if an error occurs.

int gxSocket::GetSockName() - Public member function used to retrieve the current name of the socket descriptor. It is used on a bound and/or connected socket and returns the local association. This function is especially useful when a connect call has been made without doing a bind first in which case this function provides the only means by which you can determine the local association which has been set by the system. Returns -1 if an error occurs.

int gxSocket::GetSockOpt(gxsSocket_t s, int level, int optName, void *optVal, unsigned *optLen) - Public member function used to retrieve the socket option for the specified option level or name. Returns -1 if an error occurs.

int gxSocket::GetSockOpt(int level, int optName, void *optVal, unsigned *optLen) - Public member function used to retrieve the current socket option for the specified option level or name. Returns -1 if an error occurs.

gxsSocket_t gxSocket::GetSocket() - Public member function used to retrieve the this object's socket.

gxSocketError gxSocket::GetSocketError() - Public member function used to retrieve the last reported socket error. The return value will correspond to one of the integer constants defined in the error code enumeration.

gxsSocket_t gxSocket::GetSocketType() - Public member function used to retrieve the current socket type.

gxsSocket_t gxSocket::InitSocket(gxsSocket_t st, int port, char *hostname = 0) - Public member function used to create a and initialize a socket according to the socket type: SOCK_STREAM or SOCK_DGRAM. All ports below 1024 are reserved. The "hostname" variable is an optional parameter that allows clients to specify a server name. Returns a valid socket descriptor or -1 if the socket cannot be initialized.

gxsSocket_t gxSocket::InitSocket(gxsAddressFamily af, gxsSocket_t st, gxsProtocolFamily pf, int port, char *hostname = 0) - Public member function used to create and initialize a socket according to the address family, socket type, and protocol family. The "hostname" variable is an optional parameter that allows clients to specify a server name. Returns a valid socket descriptor or -1 if the socket cannot be initialized. NOTE: Under all UNIX platforms you must have root privileges to use raw sockets. Windows 95/98/ME/NT only works with the IPPROTO_ICMP protocol when using raw sockets and does not support the IPPROTO_RAW protocol.

int gxSocket::InitSocketLibrary() - Public member function used to perform any platform specific initialization required before network communication can be established. Returns zero if no errors occur, -1 if an error occurs and the error can be mapped internally, or a value greater then zero if an error occurs and the error cannot be determined.

int gxSocket::IsBound() - Public member function that returns true if the socket is currently bound.

int gxSocket::IsConnected() - Public member function that returns true if the socket is currently connected.

int gxSocket::Listen(int max_connections = SOMAXCONN) - Public member function used to listen for connections if configured as a server. The "max_connections" variable determines how many pending connections the queue will hold. Returns -1 if an error occurs.

int gxSocket::RawRead(void *buf, int bytes, int flags = 0) - Public member function used to receive a block of data from the bound socket. NOTE: A raw read may return before all the bytes have been read. Returns the total number of bytes read or -1 if an error occurs.

int gxSocket::RawRead(gxsSocket_t s, void *buf, int bytes, int flags = 0) - Public member function used to receive a block of data from a specified socket. NOTE: A raw read may return before all the bytes have been read. Returns the total number of bytes read or -1 if an error occurs.

int gxSocket::RawReadFrom(gxsSocket_t s, gxsSocketAddress *sa, void *buf,int bytes, int flags = 0) - Public member function used to receive a block of data from a remote datagram socket. NOTE: A raw read may return before all the bytes have been read. Returns the total number of bytes read or -1 if an error occurs.

int gxSocket::RawReadFrom(void *buf, int bytes, int flags = 0) - Public member function used to receive a block of data from a remote datagram socket. NOTE: A raw read may return before all the bytes have been read. Returns the total number of bytes read or -1 if an error occurs.

int gxSocket::RawRemoteRead(void *buf, int bytes, int flags = 0) - Public member function used to receive a block of data from a remote socket. NOTE: A raw read may return before all the bytes have been read. Returns the total number of bytes read or -1 if an error occurs.

int gxSocket::RawRemoteWrite(const void *buf, int bytes, int flags = 0) - Public member function used to send a block of data to a remote socket. NOTE: A raw write may return before all the bytes have been written. Returns the total of bytes written or -1 if an error occurs.

int gxSocket::RawWrite(const void *buf, int bytes, int flags = 0) - Public member function used to send a block of data to the bound socket. NOTE: A raw write may return before all the bytes have been written. Returns the total of bytes written or -1 if an error occurs.

int gxSocket::RawWrite(gxsSocket_t s, const void *buf, int bytes, int flags = 0) - Public member function used to send a block of data to a specified socket. NOTE: A raw write may return before all the bytes have been written. Returns the total of bytes written or -1 if an error occurs.

int gxSocket::RawWriteTo(gxsSocket_t s, gxsSocketAddress *sa, void *buf,int bytes, int flags = 0) - Public member function used to send a block of data to a datagram socket. NOTE: A raw write may return before all the bytes have been written. Returns the total of bytes written or -1 if an error occurs.

int gxSocket::RawWriteTo(void *buf, int bytes, int flags = 0) - Public member function used to send a block of data to a datagram socket. NOTE: A raw write may return before all the bytes have been written. Returns the total of bytes written or -1 if an error occurs.

int gxSocket::ReadSelect(gxsSocket_t s, int seconds, int useconds) - Public member function used to multiplex reads without polling. Returns false if a reply time is longer then the timeout values.

int gxSocket::Recv(void *buf, int bytes, int flags = 0) - Public member function used to receive a block of data from the bound socket and do not return until all the bytes have been read. Returns the total number of bytes received or -1 if an error occurs.

int gxSocket::Recv(gxsSocket_t s, void *buf, int bytes, int flags = 0) - Public member function used to receive a block of data from a specified socket and do not return until all the bytes have been read. Returns the total number of bytes received or -1 if an error occurs.

int gxSocket::Recv(void *buf, int bytes, int seconds, int useconds, int flags = 0) - Public member function used to receive a block of data from the bound socket and do not return until all the bytes have been read or the timeout value has been exceeded. Returns the total number of bytes received or -1 if an error occurs.

int gxSocket::Recv(gxsSocket_t s, void *buf, int bytes, int seconds, int useconds, int flags = 0) - Public member function used to receive a block of data from a specified socket and do not return until all the bytes have been read or the timeout value has been exceeded. Returns the total number of bytes received or -1 if an error occurs.

int gxSocket::RecvFrom(gxsSocket_t s, gxsSocketAddress *sa, void *buf, int bytes, int seconds, int useconds, int flags = 0) - Public member function used to Receive a block of data from a remote datagram socket and do not return until all the bytes have been read or the timeout value has been exceeded. Returns the total number of bytes received or -1 if an error occurs.

int gxSocket::RecvFrom(gxsSocket_t s, gxsSocketAddress *sa, void *buf, int bytes, int flags = 0) - Public member function receive a block of data from a remote datagram socket and do not return until all the bytes have been read. Returns the total number of bytes received or -1 if an error occurs.

int gxSocket::RecvFrom(void *buf, int bytes, int flags = 0) - Public member function receive a block of data from a remote datagram socket and do not return until all the bytes have been read. Returns the total number of bytes received or -1 if an error occurs.

int gxSocket::RecvFrom(void *buf, int bytes, int seconds, int useconds, int flags = 0) - Public member function used to receive a block of data from a remote datagram socket and do not return until all the bytes have been read or the timeout value has been exceeded. Returns the total number of bytes received or -1 if an error occurs.

void gxSocket::ReleaseRemoteSocket() - Public member function used to release this object's remote socket without closing the socket or performing any other operation. NOTE: This function is used to reset the remote socket when more then one object is referencing the socket and the socket has been closed. You can also use a release call to signal that this object is finished with the socket and can be deleted without affecting other objects currently using this socket.

void gxSocket::ReleaseSocket() - Public member function used to release this object's socket without closing the socket or performing any other operation. NOTE: This function is used to reset the this object's socket when more then one object is referencing the socket and the socket has been closed. You can also use a release call to signal that this object is finished with the socket and can be deleted without affecting other objects currently using this socket.

int gxSocket::ReleaseSocketLibrary() - Public member function used to perform any platform specific operations required to release the socket library and free any resources associated with it. Returns -1 if any errors occur.

int gxSocket::RemoteRecv(void *buf, int bytes, int seconds, int useconds, int flags = 0) - Public member function used to receive a block of data from a remote socket in blocking mode with a specified timeout value. Returns the total number of bytes received or -1 if an error occurs.

int gxSocket::RemoteRecv(void *buf, int bytes, int flags = 0) - Public member function used to receive a block of data from a remote socket in blocking mode. Returns the total number of bytes received or -1 if an error occurs.

int gxSocket::RemoteSend(const void *buf, int bytes, int flags = 0) - Public member function used to send a block of data to a remote socket in blocking mode. Returns the total number of bytes received or -1 if an error occurs.

gxSocketError gxSocket::ResetError() - Public member function used to clear the last reported socket error.

void gxSocket::ResetRead() - Public member function used to reset the received byte count.

gxSocketError gxSocket::ResetSocketError() - Public member function used to clear the last reported socket error.

void gxSocket::ResetWrite() - Public member function used to reset the transmit byte count.

int gxSocket::Send(const void *buf, int bytes, int flags = 0) - Public member function used to send a block of data to the bound socket and do not return until all the bytes have been written. Returns the total number of bytes sent or -1 if an error occurs.

int gxSocket::Send(gxsSocket_t s, const void *buf, int bytes, int flags = 0) - Public member function used to send a block of data to a specified socket and do not return until all the bytes have been written. Returns the total number of bytes sent or -1 if an error occurs.

int gxSocket::SendTo(gxsSocket_t s, gxsSocketAddress *sa, void *buf,int bytes, int flags = 0) - Public member function used to send a block of data to a datagram socket and do not return until all the bytes have been written. Returns the total number of bytes sent or -1 if an error occurs.

int gxSocket::SendTo(void *buf, int bytes, int flags = 0) - Public member function used to send a block of data to a datagram socket and do not return until all the bytes have been written. Returns the total number of bytes sent or -1 if an error occurs.

void gxSocket::SetAddressFamily(gxsAddressFamily af) - Public member function used to set the address family. Defaults to AF_INET when a new gxSocket object is constructed.

int gxSocket::SetBytesMoved(int bytes = 0) - Public member function used to reset the transmit byte count.

int gxSocket::SetBytesRead(int bytes = 0) - Public member function used to set the received byte count.

void gxSocket::SetPortNumber(gxsPort_t p) - Public member function used to set the port number.

void gxSocket::SetProtocolFamily(gxsProtocolFamily pf) - Public member function used to set the protocol family. Defaults to IPPROTO_TCP when a new gxSocket object is constructed.

gxsSocket_t gxSocket::SetRemoteSocket(gxsSocket_t s) - Public member function used to set this object's remote socket.

int gxSocket::SetSockOpt(gxsSocket_t s, int level, int optName, const void *optVal, unsigned optLen) - Public member function used to set the socket option for the specified option level or name. Returns -1 if an error occurs.

int gxSocket::SetSockOpt(int level, int optName, const void *optVal, unsigned optLen) - Public member function used to set this object's socket option for the specified option level or name. Returns -1 if an error occurs.

gxsSocket_t gxSocket::SetSocket(gxsSocket_t s) - Public member function used to set this object's socket.

gxSocketError gxSocket::SetSocketError(gxSocketError err) - Public member function used to set the socket error code. The "err" variable must correspond to one to the integer constants defined in the error code enumeration.

void gxSocket::SetSocketType(gxsSocket_t st) - Public member function used to set the socket type. Defaults to SOCK_STREAM when a new gxSocket object is constructed.

void gxSocket::ShutDown(int how = 0) - Public member function used to close and un-initialize a full-duplex socket. The "how" variable must equal one of the following values: 0 = user is no longer interested in reading data, 1 = no more data will be sent, or 2 = no data is to be sent or received.

void gxSocket::ShutDown(gxsSocket_t &s, int how = 0) - Public member function used to close and un-initialize the specified full-duplex socket. The "how" variable must equal one of the following values: 0 = user is no longer interested in reading data, 1 = no more data will be sent, or 2 = no data is to be sent or received.

void gxSocket::ShutDownRemoteSocket(int how = 0) - Public member function used to close a full-duplex client side socket. The "how" variable must equal one of the following values: 0 = user is no longer interested in reading data, 1 = no more data will be sent, or 2 = no data is to be sent or received.

void gxSocket::ShutDownSocket(int how = 0) - Public member function used to close a full-duplex server side socket. The "how" variable must equal one of the following values: 0 = user is no longer interested in reading data, 1 = no more data will be sent, or 2 = no data is to be sent or received.

gxsSocket_t gxSocket::Socket() - Public member function used to create a socket. Returns a valid socket descriptor or -1 if the socket cannot be initialized.

const char *gxSocket::SocketExceptionMessage() - Public member function that returns a null-terminated string that can be use to log or print a socket exception.


End Of Document