Public Member Functions | |
NetworkEndpointInstanceTCP (NetworkModule *pNetworkModule) | |
virtual | ~NetworkEndpointInstanceTCP () |
virtual eError | Close (uint_t bOrderly) |
Close and dispose of a NetworkEndpointInstance. | |
virtual eError | AcceptConnection (CallbackProc pCallback, void *pContext, void *pExtra) |
Accept a remote connection request. | |
virtual eError | RejectConnection (void *pExtra) |
Reject a remote connection request. | |
virtual uint_t | IsAlive (void) |
Test if a stream connection with a remote machine is still active. | |
virtual eError | SetTimeOut (uint32_t uTimeout=kDefaultTimeout) |
Set the endpoint instance time in milliseconds. | |
virtual eError | StartAdvertising (void) |
Enable listening for broadcast packets. | |
virtual eError | StopAdvertising (void) |
Disable listening for broadcast packets. | |
virtual eError | Poll (void) noexcept |
Poll for events. | |
virtual eError | Send (uintptr_t *pBytesSent, const void *pData, uintptr_t uDataSize, eBlockMode uMode=kNonBlocking) |
Send data using guaranteed protocol. | |
virtual eError | Receive (uintptr_t *pBytesReceived, void *pData, uintptr_t uDataSize) |
Receive data using guaranteed protocol. | |
virtual eError | SendDatagram (uintptr_t *pBytesSent, const void *pData, uintptr_t uDataSize, eBlockMode uMode=kNonBlocking) |
Send data using datagram protocol. | |
virtual eError | ReceiveDatagram (uintptr_t *pBytesReceived, void *pData, uintptr_t uDataSize) |
Receive data using non-guaranteed protocol. | |
eError | TransmitData (uintptr_t *pBytesSent, eSocketIndexes uIndex, const void *pData, uintptr_t uDataSize, eBlockMode uMode=NetworkEndpointInstance::kNonBlocking) |
eError | ReceiveData (uintptr_t *pBytesReceived, eSocketIndexes uIndex, void *pData, uintptr_t uDataSize) |
eError | SetupSockets (eSocketIndexes uIndex, const NetAddr_t *pAddress, NetworkEndpoint::eOpenType uOpenType, const uintptr_t *pSockets) |
eError | WaitingForOpen (void) |
void | ProcessSocket (eSocketIndexes uIndex, void *pInputSet, void *pOutputSet, void *pExecSet) |
void | SendDatagramSocket (void) |
uint_t | HandleRead (eSocketIndexes uIndex) |
Public Member Functions inherited from Burger::NetworkEndpointInstance | |
NetworkEndpointInstance (NetworkModule *pNetworkModule) | |
Default constructor. | |
virtual | ~NetworkEndpointInstance () |
Default destructor. | |
NetworkModule * | GetNetworkModule (void) const |
Return the pointer to the parent NetworkModule. | |
eError | GetLocalAddress (String *pOutput) |
Return the address of the local endpoint. | |
eError | GetRemoteAddress (String *pOutput) |
Return the address of the remote endpoint. | |
eError | NotificationLock (eSocketFlags uFlags) |
Obtain the endpoint lock. | |
eError | NotificationUnlock (eSocketFlags uFlags) |
Release the endpoint lock. | |
Static Public Member Functions | |
static eError | CreateMatchingSockets (uintptr_t *pSockets, const NetAddr_t *pAddress, NetworkEndpoint::eOpenType uOpenType) |
Public Attributes | |
NetworkEndpointInstance * | m_pNextEndpointInstance |
Linked list of attached sockets. | |
NetworkEndpointInstance * | m_pParentInstance |
Set to point to a parent socket if this is a child. | |
CallbackProc | m_pCallback |
Callback for this instance. | |
void * | m_pCallbackContext |
Context for this instance. | |
uint32_t | m_uGameID |
GameID this endpoint belongs to. | |
uint32_t | m_uTimeOut |
Timeout value. | |
eSocketFlags | m_uSocketFlags |
Datagram/stream desired. | |
eSocketFlags | m_uValidEndpoints |
Datagram/stream valid. | |
eError | m_uError |
Error state. | |
uint_t | m_bAdvertising |
TRUE if the endpoint is advertising its existence | |
uint_t | m_bActive |
TRUE if the endpoint is active | |
uint_t | m_bListening |
TRUE if the endpoint is listening for data | |
uint_t | m_bPassiveMode |
TRUE Enable passive mode | |
uint_t | m_bAlive |
TRUE if this endpoint is alive and connected elsewhere | |
uint_t | m_bIsDying |
TRUE if this endpoint is in the process of shutting down | |
uint_t | m_bKillMe |
TRUE if this endpoint should shut down | |
uint_t | m_bFlowsBlocked [kSocketIndexCount] |
TRUE if the datagram/stream is blocked | |
uint_t | m_bCallbackSent [kSocketIndexCount] |
TRUE if the datagram/stream has issued a callback | |
String | m_GameName |
Name of the game owning this endpoint. | |
uintptr_t | m_uSockets [kSocketIndexCount] |
Datagram and stream sockets. | |
uint_t | m_bDynamicallyAssignedRemotePort |
TRUE if the port was to be dynamically assigned | |
Private Member Functions | |
NetworkEndpointInstanceTCP (const NetworkEndpointInstanceTCP &)=delete | |
NetworkEndpointInstanceTCP & | operator= (const NetworkEndpointInstanceTCP &)=delete |
NetworkEndpointInstanceTCP (NetworkEndpointInstanceTCP &&)=delete | |
NetworkEndpointInstanceTCP & | operator= (NetworkEndpointInstanceTCP &&)=delete |
Additional Inherited Members | |
Public Types inherited from Burger::NetworkEndpointInstance | |
enum | eCallbackCode { kConnectionRequest , kAcceptionComplete , kHandoffComplete , kClosed , kDied , kUnblocked , kDatagramReceived , kStreamDataReceived , kPreprocessResponse } |
Callback code for endpoint instance events. More... | |
enum | eBlockMode { kNonBlocking , kBlocking } |
Flag for enabling or disabling blocking on data transmission. More... | |
typedef void(*) | CallbackProc(void *pContext, eCallbackCode uCode, NetworkEndpointInstance *pInstance, eError uError, void *pExtra) |
Function prototype for event callbacks. | |
Static Public Attributes inherited from Burger::NetworkEndpointInstance | |
static const uint32_t | kDefaultTimeout = 5000 |
In milliseconds, 5 second timeout. | |
Protected Attributes inherited from Burger::NetworkEndpointInstance | |
NetworkModule * | m_pNetworkModule |
Pointer to the parent NetworkModule. | |
NetAddr_t | m_LocalAddress |
Network address for local endpoint (All protocols supported) | |
NetAddr_t | m_RemoteAddress |
Network address for connected endpoint (All protocols supported) | |
|
privatedelete |
|
privatedelete |
Burger::NetworkEndpointInstanceTCP::NetworkEndpointInstanceTCP | ( | NetworkModule * | pNetworkModule | ) |
|
virtual |
|
virtual |
Accept a remote connection request.
Attempt to connect to the remote endpoint. This can fail if the connection was interrupted before it could be acknowledged.
pCallback | Pointer to a callback function that will be called to determine if a connection should be accepted or rejected. |
pContext | Pointer to a context for the callback function. |
pExtra | Pointer to the Endpoint that issued this accept request. |
Implements Burger::NetworkEndpointInstance.
Close and dispose of a NetworkEndpointInstance.
Close an endpoint and if bOrderly is set to TRUE, issue calls to the network driver to notify any connected remote machine that this endpoint is to be shut down and disposed of. If bOrderly is FALSE, the socket is torn down and no attempt is made to notify the machine on the other side.
Implements Burger::NetworkEndpointInstance.
|
static |
uint_t Burger::NetworkEndpointInstanceTCP::HandleRead | ( | eSocketIndexes | uIndex | ) |
|
virtual |
Test if a stream connection with a remote machine is still active.
If a connection with a remote machine is active, return TRUE. Otherwise if the endpoint is invalid or not connected, it will return FALSE.
Implements Burger::NetworkEndpointInstance.
|
privatedelete |
|
privatedelete |
|
virtualnoexcept |
Poll for events.
On some platforms, endpoints require some CPU time from the application to perform housekeeping actions. Most platforms, this call performs no action because the network layer is all performed in its own thread.
Implements Burger::NetworkEndpointInstance.
void Burger::NetworkEndpointInstanceTCP::ProcessSocket | ( | eSocketIndexes | uIndex, |
void * | pInputSet, | ||
void * | pOutputSet, | ||
void * | pExecSet ) |
|
virtual |
Receive data using guaranteed protocol.
If this endpoint is connected to a remote endpoint, check if the endpoint has data pending and if so, fill the buffer with as many bytes that can be obtained. Set pBytesReceived with the actual number of bytes read in, this value can be zero.
pBytesReceived | Pointer to a value that will obtain the number of bytes received during this call. |
pData | Pointer to a data buffer to hold the received data. |
uDataSize | Size of the buffer that will hold the received data. |
Implements Burger::NetworkEndpointInstance.
eError Burger::NetworkEndpointInstanceTCP::ReceiveData | ( | uintptr_t * | pBytesReceived, |
eSocketIndexes | uIndex, | ||
void * | pData, | ||
uintptr_t | uDataSize ) |
|
virtual |
Receive data using non-guaranteed protocol.
If this endpoint is listening for packets, check if there is data pending and if so, fill the buffer with as many bytes that can be obtained. Set pBytesReceived with the actual number of bytes read in, this value can be zero.
pBytesReceived | Pointer to a value that will obtain the number of bytes received during this call. |
pData | Pointer to a data buffer to hold the received data. |
uDataSize | Size of the buffer that will hold the received data. |
Implements Burger::NetworkEndpointInstance.
|
virtual |
Reject a remote connection request.
Reject a connection to a remote endpoint.
pExtra | Pointer to the Endpoint that issued an accept request that should be rejected. |
Implements Burger::NetworkEndpointInstance.
|
virtual |
Send data using guaranteed protocol.
If this endpoint is connected to a remote endpoint, send data to that endpoint. This function can block until data is in the queue. If the function is not blocked, check the returned pBytesSent value to determine how much data couldn't be sent due to issues such at data blockage.
pBytesSent | Pointer to a value that will obtain the number of bytes sent during this call. |
pData | Pointer to a data buffer to transmit. |
uDataSize | Number of bytes to transmit. |
uMode | Either kBlocking if this function should block until error or all data is send or kNonBlocking if the function should return as soon as possible. |
Implements Burger::NetworkEndpointInstance.
|
virtual |
Send data using datagram protocol.
If this endpoint has an address for a destination endpoint, send data to that endpoint. This function can block until data is in the queue. If the function is not blocked, check the returned pBytesSent value to determine how much data couldn't be sent due to issues such at data blockage.
pBytesSent | Pointer to a value that will obtain the number of bytes sent during this call. |
pData | Pointer to a data buffer to transmit. |
uDataSize | Number of bytes to transmit. |
uMode | Either kBlocking if this function should block until error or all data is send or kNonBlocking if the function should return as soon as possible. |
Implements Burger::NetworkEndpointInstance.
void Burger::NetworkEndpointInstanceTCP::SendDatagramSocket | ( | void | ) |
|
virtual |
Set the endpoint instance time in milliseconds.
Set the timeout value for this endpoint instance in milliseconds.
uTimeout | Timeout in milliseconds, 5 seconds is the default. kDefaultTimeout |
Implements Burger::NetworkEndpointInstance.
eError Burger::NetworkEndpointInstanceTCP::SetupSockets | ( | eSocketIndexes | uIndex, |
const NetAddr_t * | pAddress, | ||
NetworkEndpoint::eOpenType | uOpenType, | ||
const uintptr_t * | pSockets ) |
|
virtual |
Enable listening for broadcast packets.
When creating a game server, it may wish to advertise its existence to the local network. This function enables the ability for this endpoint to listen for broadcast packets from a client asking for information about this server.
Implements Burger::NetworkEndpointInstance.
|
virtual |
Disable listening for broadcast packets.
When creating a game server, it may wish to advertise its existence to the local network. This function disables the ability for this endpoint to listen for broadcast packets from a client asking for information about this server.
Implements Burger::NetworkEndpointInstance.
eError Burger::NetworkEndpointInstanceTCP::TransmitData | ( | uintptr_t * | pBytesSent, |
eSocketIndexes | uIndex, | ||
const void * | pData, | ||
uintptr_t | uDataSize, | ||
eBlockMode | uMode = NetworkEndpointInstance::kNonBlocking ) |
eError Burger::NetworkEndpointInstanceTCP::WaitingForOpen | ( | void | ) |
uint_t Burger::NetworkEndpointInstanceTCP::m_bAdvertising |
TRUE if the endpoint is advertising its existence
uint_t Burger::NetworkEndpointInstanceTCP::m_bAlive |
TRUE if this endpoint is alive and connected elsewhere
uint_t Burger::NetworkEndpointInstanceTCP::m_bCallbackSent[kSocketIndexCount] |
TRUE if the datagram/stream has issued a callback
uint_t Burger::NetworkEndpointInstanceTCP::m_bDynamicallyAssignedRemotePort |
TRUE if the port was to be dynamically assigned
uint_t Burger::NetworkEndpointInstanceTCP::m_bFlowsBlocked[kSocketIndexCount] |
TRUE if the datagram/stream is blocked
uint_t Burger::NetworkEndpointInstanceTCP::m_bIsDying |
TRUE if this endpoint is in the process of shutting down
String Burger::NetworkEndpointInstanceTCP::m_GameName |
Name of the game owning this endpoint.
CallbackProc Burger::NetworkEndpointInstanceTCP::m_pCallback |
Callback for this instance.
void* Burger::NetworkEndpointInstanceTCP::m_pCallbackContext |
Context for this instance.
NetworkEndpointInstance* Burger::NetworkEndpointInstanceTCP::m_pNextEndpointInstance |
Linked list of attached sockets.
NetworkEndpointInstance* Burger::NetworkEndpointInstanceTCP::m_pParentInstance |
Set to point to a parent socket if this is a child.
eError Burger::NetworkEndpointInstanceTCP::m_uError |
Error state.
uint32_t Burger::NetworkEndpointInstanceTCP::m_uGameID |
GameID this endpoint belongs to.
eSocketFlags Burger::NetworkEndpointInstanceTCP::m_uSocketFlags |
Datagram/stream desired.
uintptr_t Burger::NetworkEndpointInstanceTCP::m_uSockets[kSocketIndexCount] |
Datagram and stream sockets.
uint32_t Burger::NetworkEndpointInstanceTCP::m_uTimeOut |
Timeout value.
eSocketFlags Burger::NetworkEndpointInstanceTCP::m_uValidEndpoints |
Datagram/stream valid.