#include <SocketLayer.h>
Public Member Functions | |
SocketLayer () | |
Default Constructor. | |
~SocketLayer () | |
SOCKET | Connect (SOCKET writeSocket, unsigned int binaryAddress, unsigned short port) |
SOCKET | CreateBoundSocket (unsigned short port, bool blockingSocket, const char *forceHostAddress, unsigned int sleepOn10048) |
SOCKET | CreateBoundSocket_PS3Lobby (unsigned short port, bool blockingSocket, const char *forceHostAddress) |
const char * | DomainNameToIP (const char *domainName) |
bool | AssociateSocketWithCompletionPortAndRead (SOCKET readSocket, unsigned int binaryAddress, unsigned short port, RakPeer *rakPeer) |
void | Write (const SOCKET writeSocket, const char *data, const int length) |
int | RecvFrom (const SOCKET s, RakPeer *rakPeer, int *errorCode, RakNetSmartPtr< RakNetSocket > rakNetSocket, unsigned short remotePortRakNetWasStartedOn_PS3) |
void | RawRecvFromNonBlocking (const SOCKET s, unsigned short remotePortRakNetWasStartedOn_PS3, char *dataOut, int *bytesReadOut, SystemAddress *systemAddressOut, RakNetTimeUS *timeRead) |
RakNet::RakString | GetSubNetForSocketAndIp (SOCKET inSock, RakNet::RakString inIpString) |
void | SetNonBlocking (SOCKET listenSocket) |
void | GetMyIP (char ipList[MAXIMUM_NUMBER_OF_INTERNAL_IDS][16], unsigned int binaryAddresses[MAXIMUM_NUMBER_OF_INTERNAL_IDS]) |
int | SendTo (SOCKET s, const char *data, int length, const char ip[16], unsigned short port, unsigned short remotePortRakNetWasStartedOn_PS3) |
int | SendToTTL (SOCKET s, const char *data, int length, const char ip[16], unsigned short port, int ttl) |
int | SendTo (SOCKET s, const char *data, int length, unsigned int binaryAddress, unsigned short port, unsigned short remotePortRakNetWasStartedOn_PS3) |
void | SetSocketLayerOverride (SocketLayerOverride *_slo) |
SocketLayerOverride * | GetSocketLayerOverride (void) const |
int | SendTo_PS3Lobby (SOCKET s, const char *data, int length, unsigned int binaryAddress, unsigned short port, unsigned short remotePortRakNetWasStartedOn_PS3) |
int | SendTo_360 (SOCKET s, const char *data, int length, const char *voiceData, int voiceLength, unsigned int binaryAddress, unsigned short port) |
int | SendTo_PC (SOCKET s, const char *data, int length, unsigned int binaryAddress, unsigned short port) |
Static Public Member Functions | |
static SocketLayer * | Instance () |
static bool | IsPortInUse (unsigned short port, const char *hostAddress=0) |
static void | RecvFromBlocking (const SOCKET s, RakPeer *rakPeer, unsigned short remotePortRakNetWasStartedOn_PS3, char *dataOut, int *bytesReadOut, SystemAddress *systemAddressOut, RakNetTimeUS *timeRead) |
static unsigned short | GetLocalPort (SOCKET s) |
static SystemAddress | GetSystemAddress (SOCKET s) |
static void | SetDoNotFragment (SOCKET listenSocket, int opt) |
Definition at line 42 of file SocketLayer.h.
SocketLayer::SocketLayer | ( | ) |
Default Constructor.
Definition at line 67 of file SocketLayer.cpp.
SocketLayer::~SocketLayer | ( | ) |
bool SocketLayer::AssociateSocketWithCompletionPortAndRead | ( | SOCKET | readSocket, | |
unsigned int | binaryAddress, | |||
unsigned short | port, | |||
RakPeer * | rakPeer | |||
) |
Start an asynchronous read using the specified socket. The callback will use the specified SystemAddress (associated with this socket) and call either the client or the server callback (one or the other should be 0)
[in] | writeSocket | The local socket. |
[in] | binaryAddress | The address of the remote host. |
[in] | port | the remote port. |
Definition at line 82 of file SocketLayer.cpp.
SOCKET SocketLayer::CreateBoundSocket | ( | unsigned short | port, | |
bool | blockingSocket, | |||
const char * | forceHostAddress, | |||
unsigned int | sleepOn10048 | |||
) |
Creates a bound socket to listen for incoming connections on the specified port
[in] | port | the port number |
[in] | blockingSocket |
Definition at line 257 of file SocketLayer.cpp.
SOCKET SocketLayer::CreateBoundSocket_PS3Lobby | ( | unsigned short | port, | |
bool | blockingSocket, | |||
const char * | forceHostAddress | |||
) |
const char * SocketLayer::DomainNameToIP | ( | const char * | domainName | ) |
unsigned short SocketLayer::GetLocalPort | ( | SOCKET | s | ) | [static] |
Returns the local port, useful when passing 0 as the startup port.
[in] | s | The socket whose port we are referring to |
Definition at line 1106 of file SocketLayer.cpp.
void SocketLayer::GetMyIP | ( | char | ipList[MAXIMUM_NUMBER_OF_INTERNAL_IDS][16], | |
unsigned int | binaryAddresses[MAXIMUM_NUMBER_OF_INTERNAL_IDS] | |||
) |
Retrieve all local IP address in a string format.
[in] | s | The socket whose port we are referring to |
[in] | ipList | An array of ip address in dotted notation. |
Definition at line 1094 of file SocketLayer.cpp.
SocketLayerOverride* SocketLayer::GetSocketLayerOverride | ( | void | ) | const [inline] |
RakNet::RakString SocketLayer::GetSubNetForSocketAndIp | ( | SOCKET | inSock, | |
RakNet::RakString | inIpString | |||
) |
Given a socket and IP, retrieves the subnet mask, on linux the socket is unused
[in] | inSock | the socket |
[in] | inIpString | The ip of the interface you wish to retrieve the subnet mask from |
Definition at line 908 of file SocketLayer.cpp.
SystemAddress SocketLayer::GetSystemAddress | ( | SOCKET | s | ) | [static] |
static SocketLayer* SocketLayer::Instance | ( | ) | [inline, static] |
Definition at line 55 of file SocketLayer.h.
bool SocketLayer::IsPortInUse | ( | unsigned short | port, | |
const char * | hostAddress = 0 | |||
) | [static] |
Returns if this specified port is in use, for UDP
[in] | port | the port number |
Definition at line 109 of file SocketLayer.cpp.
void SocketLayer::RawRecvFromNonBlocking | ( | const SOCKET | s, | |
unsigned short | remotePortRakNetWasStartedOn_PS3, | |||
char * | dataOut, | |||
int * | bytesReadOut, | |||
SystemAddress * | systemAddressOut, | |||
RakNetTimeUS * | timeRead | |||
) |
Read raw unprocessed data from the socket
[in] | s | the socket |
[in] | remotePortRakNetWasStartedOn_PS3 | was started on the PS3? |
[out] | dataOut | The data read |
[out] | bytesReadOut | Number of bytes read, -1 if nothing was read |
[out] | systemAddressOut | Who is sending the packet |
[out] | timeRead | Time that thre read occured |
Definition at line 620 of file SocketLayer.cpp.
int SocketLayer::RecvFrom | ( | const SOCKET | s, | |
RakPeer * | rakPeer, | |||
int * | errorCode, | |||
RakNetSmartPtr< RakNetSocket > | rakNetSocket, | |||
unsigned short | remotePortRakNetWasStartedOn_PS3 | |||
) |
Read data from a socket
[in] | s | the socket |
[in] | rakPeer | The instance of rakPeer containing the recvFrom C callback |
[in] | errorCode | An error code if an error occured . |
[in] | connectionSocketIndex | Which of the sockets in RakPeer we are using |
Definition at line 394 of file SocketLayer.cpp.
void SocketLayer::RecvFromBlocking | ( | const SOCKET | s, | |
RakPeer * | rakPeer, | |||
unsigned short | remotePortRakNetWasStartedOn_PS3, | |||
char * | dataOut, | |||
int * | bytesReadOut, | |||
SystemAddress * | systemAddressOut, | |||
RakNetTimeUS * | timeRead | |||
) | [static] |
Definition at line 539 of file SocketLayer.cpp.
int SocketLayer::SendTo | ( | SOCKET | s, | |
const char * | data, | |||
int | length, | |||
unsigned int | binaryAddress, | |||
unsigned short | port, | |||
unsigned short | remotePortRakNetWasStartedOn_PS3 | |||
) |
Call sendto (UDP obviously)
[in] | s | the socket |
[in] | data | The byte buffer to send |
[in] | length | The length of the data in bytes |
[in] | binaryAddress | The address of the remote host in binary format. |
[in] | port | The port number to send to. |
Definition at line 777 of file SocketLayer.cpp.
int SocketLayer::SendTo | ( | SOCKET | s, | |
const char * | data, | |||
int | length, | |||
const char | ip[16], | |||
unsigned short | port, | |||
unsigned short | remotePortRakNetWasStartedOn_PS3 | |||
) |
Call sendto (UDP obviously)
[in] | s | the socket |
[in] | data | The byte buffer to send |
[in] | length | The length of the data in bytes |
[in] | ip | The address of the remote host in dotted notation. |
[in] | port | The port number to send to. |
Definition at line 843 of file SocketLayer.cpp.
int SocketLayer::SendTo_360 | ( | SOCKET | s, | |
const char * | data, | |||
int | length, | |||
const char * | voiceData, | |||
int | voiceLength, | |||
unsigned int | binaryAddress, | |||
unsigned short | port | |||
) |
int SocketLayer::SendTo_PC | ( | SOCKET | s, | |
const char * | data, | |||
int | length, | |||
unsigned int | binaryAddress, | |||
unsigned short | port | |||
) |
int SocketLayer::SendTo_PS3Lobby | ( | SOCKET | s, | |
const char * | data, | |||
int | length, | |||
unsigned int | binaryAddress, | |||
unsigned short | port, | |||
unsigned short | remotePortRakNetWasStartedOn_PS3 | |||
) |
int SocketLayer::SendToTTL | ( | SOCKET | s, | |
const char * | data, | |||
int | length, | |||
const char | ip[16], | |||
unsigned short | port, | |||
int | ttl | |||
) |
Call sendto (UDP obviously) It won't reach the recipient, except on a LAN However, this is good for opening routers / firewalls
[in] | s | the socket |
[in] | data | The byte buffer to send |
[in] | length | The length of the data in bytes |
[in] | ip | The address of the remote host in dotted notation. |
[in] | port | The port number to send to. |
[in] | ttl | Max hops of datagram |
Definition at line 849 of file SocketLayer.cpp.
void SocketLayer::SetDoNotFragment | ( | SOCKET | listenSocket, | |
int | opt | |||
) | [static] |
void SocketLayer::SetNonBlocking | ( | SOCKET | listenSocket | ) |
Sets the socket flags to nonblocking
[in] | listenSocket | the socket to set |
Definition at line 161 of file SocketLayer.cpp.
void SocketLayer::SetSocketLayerOverride | ( | SocketLayerOverride * | _slo | ) |
Definition at line 1158 of file SocketLayer.cpp.
void SocketLayer::Write | ( | const SOCKET | writeSocket, | |
const char * | data, | |||
const int | length | |||
) |
Write data of length length to writeSocket
[in] | writeSocket | The socket to write to |
[in] | data | The data to write |
[in] | length | The length of data |
Definition at line 386 of file SocketLayer.cpp.