ReplicaNet and RNLobby
1
|
#include <XPSocketClass.h>
Public Member Functions | |
XPSocket () | |
virtual | ~XPSocket () |
virtual int | Create (void) |
int | Connect (const XPAddress &addr) |
int | Send (const char *data) |
int | Send (const char *data, const int len) |
int | Recv (char *const data, const int maxlen) |
int | Close (void) |
int | Listen (const int port=XPSOCK_PORT_ANY) |
int | Listen (const XPAddress &addr) |
XPSocket * | Accept (void) |
int | SetSendBuffer (const int size) |
int | SetRecvBuffer (const int size) |
int | GetAddress (XPAddress *const addr) |
int | GetPeerAddress (XPAddress *const addr) |
int | MutateSocket (XPSocket *socket) |
bool | IsAlive (void) |
t_XPSocket * | GetSocketPointer (void) |
Static Public Member Functions | |
static int | GetLastError (void) |
static int | GetMaxPacketSize (void) |
Friends | |
class | XPSocketUrgent |
This class is a socket which is a potential connection or actual connection to a machine. This uses the underlying XPSocket library which in turn uses the winsock or berkley sockets API. Most member functions return an XPSOCK_EERROR code. XPSOCK_EOK indicates no error. XPSOCK_EWOULDBLOCK is a non-fatal error and means the socket operation would have blocked the current thread at this point. If XPSOCK_EERROR is returned the user should use XPSocket::GetLastError() to find out the actual error code
XPSocket | ( | ) |
The ctor for an XPSocket This checks to make sure sockets are active and sets some initial states. At this point no connection is made for the socket
References XPSock_Init().
Referenced by XPSocket::Accept().
|
virtual |
The dtor for an XPSocket This cleans up everything for this socket
References XPSocket::Close().
XPSocket * Accept | ( | void | ) |
Accepts any pending connections for this socket. This should be used with the Listen() member function
References XPSock_Accept(), and XPSocket::XPSocket().
int Close | ( | void | ) |
Closes the socket but does not delete the memory for the XPSocket class
References XPSock_Close().
Referenced by XPSocket::~XPSocket().
int Connect | ( | const XPAddress & | addr | ) |
Tries to connect this socket to a network address
addr | the address to try to connect to |
References XPSock_Connect().
|
virtual |
Creates a TCP style socket. This is the first stage to creating a connection
References XPSock_Create().
int GetAddress | ( | XPAddress *const | addr | ) |
Fills in the internet address and port of the socket to the address structure.
addr | the address structure to fill in |
References XPSock_GetAddress().
|
static |
Gets the last error reported by the XPSocket API
References asocket_lasterror.
|
inlinestatic |
Returns the maximum size for a packet
int GetPeerAddress | ( | XPAddress *const | addr | ) |
Fills in the internet address of the peer of the socket to the address structure.
addr | the address structure to fill in |
References XPSock_GetPeerAddress().
t_XPSocket * GetSocketPointer | ( | void | ) |
Access for the t_XPSocket pointer
bool IsAlive | ( | void | ) |
Tests the alive state of the socket
int Listen | ( | const int | port = XPSOCK_PORT_ANY | ) |
Makes the socket listen on a certain port number
port | the port number to listen on for incoming connections |
References XPSock_Listen().
int Listen | ( | const XPAddress & | addr | ) |
Makes the socket listen on a certain address
addr | the address to listen on for incoming connections |
References XPSock_Listen().
int MutateSocket | ( | XPSocket * | socket | ) |
Mutates this socket class to use a socket
socket | the socket to mutate to |
References XPSock_Close().
int Recv | ( | char *const | data, |
const int | maxlen | ||
) |
Tries to receive data that is waiting for this socket
data | the pointer to the buffer to receive the data |
maxlen | the maximum length of the data buffer |
References XPSock_Recv().
int Send | ( | const char * | data | ) |
Sends a NULL terminated string to the peer (the connected machine) for this socket
data | The pointer to the NULL terminated string |
References XPSock_Send().
int Send | ( | const char * | data, |
const int | len | ||
) |
Sends data to the peer (the connected machine) for this socket
data | the pointer to the data to send |
len | the length of the data to send |
References XPSock_Send().
int SetRecvBuffer | ( | const int | size | ) |
Sets the size of the recv buffer for the socket
size | The size to set the recv buffer to or -1 to only return the value |
References XPSock_SetRecvBuffer().
int SetSendBuffer | ( | const int | size | ) |
Sets the size of the send buffer for the socket
size | The size to set the send buffer to or -1 to only return the value |
References XPSock_SetSendBuffer().