Public Member Functions | Static Public Member Functions

SocketLayer Class Reference

#include <SocketLayer.h>

Collaboration diagram for SocketLayer:
Collaboration graph
[legend]

List of all members.

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)
SocketLayerOverrideGetSocketLayerOverride (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 SocketLayerInstance ()
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)

Detailed Description

Definition at line 42 of file SocketLayer.h.


Constructor & Destructor Documentation

SocketLayer::SocketLayer (  ) 

Default Constructor.

Definition at line 67 of file SocketLayer.cpp.

Here is the call graph for this function:

SocketLayer::~SocketLayer (  ) 

Definition at line 75 of file SocketLayer.cpp.

Here is the call graph for this function:


Member Function Documentation

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)

Note:
Was used for deprecated IO completion ports.
SOCKET SocketLayer::Connect ( SOCKET  writeSocket,
unsigned int  binaryAddress,
unsigned short  port 
)
Parameters:
[in] writeSocket The local socket.
[in] binaryAddress The address of the remote host.
[in] port the remote port.
Returns:
A new socket used for communication.

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

Parameters:
[in] port the port number
[in] blockingSocket 
Returns:
A new socket used for accepting clients

Definition at line 257 of file SocketLayer.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

SOCKET SocketLayer::CreateBoundSocket_PS3Lobby ( unsigned short  port,
bool  blockingSocket,
const char *  forceHostAddress 
)

Definition at line 245 of file SocketLayer.cpp.

Here is the caller graph for this function:

const char * SocketLayer::DomainNameToIP ( const char *  domainName  ) 

Definition at line 360 of file SocketLayer.cpp.

Here is the caller graph for this function:

unsigned short SocketLayer::GetLocalPort ( SOCKET  s  )  [static]

Returns the local port, useful when passing 0 as the startup port.

Parameters:
[in] s The socket whose port we are referring to
Returns:
The local port

Definition at line 1106 of file SocketLayer.cpp.

Here is the caller graph for this function:

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.

Parameters:
[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.

Here is the call graph for this function:

Here is the caller graph for this function:

SocketLayerOverride* SocketLayer::GetSocketLayerOverride ( void   )  const [inline]

Definition at line 168 of file SocketLayer.h.

Here is the caller graph for this function:

RakNet::RakString SocketLayer::GetSubNetForSocketAndIp ( SOCKET  inSock,
RakNet::RakString  inIpString 
)

Given a socket and IP, retrieves the subnet mask, on linux the socket is unused

Parameters:
[in] inSock the socket
[in] inIpString The ip of the interface you wish to retrieve the subnet mask from
Returns:
Returns the ip dotted subnet mask if successful, otherwise returns empty string ("")

Definition at line 908 of file SocketLayer.cpp.

SystemAddress SocketLayer::GetSystemAddress ( SOCKET  s  )  [static]

Definition at line 1130 of file SocketLayer.cpp.

Here is the caller graph for this function:

static SocketLayer* SocketLayer::Instance (  )  [inline, static]
Returns:
unique instance

Definition at line 55 of file SocketLayer.h.

Here is the caller graph for this function:

bool SocketLayer::IsPortInUse ( unsigned short  port,
const char *  hostAddress = 0 
) [static]

Returns if this specified port is in use, for UDP

Parameters:
[in] port the port number
Returns:
If this port is already in use

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

Parameters:
[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.

Here is the call graph for this function:

int SocketLayer::RecvFrom ( const SOCKET  s,
RakPeer rakPeer,
int *  errorCode,
RakNetSmartPtr< RakNetSocket rakNetSocket,
unsigned short  remotePortRakNetWasStartedOn_PS3 
)

Read data from a socket

Parameters:
[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
Returns:
Returns true if you successfully read data, false on error.

Definition at line 394 of file SocketLayer.cpp.

Here is the call graph for this function:

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.

Here is the call graph for this function:

Here is the caller graph for this function:

int SocketLayer::SendTo ( SOCKET  s,
const char *  data,
int  length,
unsigned int  binaryAddress,
unsigned short  port,
unsigned short  remotePortRakNetWasStartedOn_PS3 
)

Call sendto (UDP obviously)

Parameters:
[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.
Returns:
0 on success, nonzero on failure.

Definition at line 777 of file SocketLayer.cpp.

Here is the call graph for this function:

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)

Parameters:
[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.
Returns:
0 on success, nonzero on failure.

Definition at line 843 of file SocketLayer.cpp.

Here is the caller graph for this function:

int SocketLayer::SendTo_360 ( SOCKET  s,
const char *  data,
int  length,
const char *  voiceData,
int  voiceLength,
unsigned int  binaryAddress,
unsigned short  port 
)

Definition at line 692 of file SocketLayer.cpp.

Here is the caller graph for this function:

int SocketLayer::SendTo_PC ( SOCKET  s,
const char *  data,
int  length,
unsigned int  binaryAddress,
unsigned short  port 
)

Definition at line 731 of file SocketLayer.cpp.

Here is the caller graph for this function:

int SocketLayer::SendTo_PS3Lobby ( SOCKET  s,
const char *  data,
int  length,
unsigned int  binaryAddress,
unsigned short  port,
unsigned short  remotePortRakNetWasStartedOn_PS3 
)

Definition at line 677 of file SocketLayer.cpp.

Here is the caller graph for this function:

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

Parameters:
[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
Returns:
0 on success, nonzero on failure.

Definition at line 849 of file SocketLayer.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void SocketLayer::SetDoNotFragment ( SOCKET  listenSocket,
int  opt 
) [static]

Definition at line 135 of file SocketLayer.cpp.

Here is the caller graph for this function:

void SocketLayer::SetNonBlocking ( SOCKET  listenSocket  ) 

Sets the socket flags to nonblocking

Parameters:
[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

Parameters:
[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.


The documentation for this class was generated from the following files: