Kicking it Olde Sküül! Burgerlib on Github Follow Olde Sküül on Twitter Burgerbecky on LinkedIn Burgerbecky on LinkedIn
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Public Attributes | Private Member Functions | List of all members
Burger::NetworkEndpointInstanceTCP Class Reference
Inheritance diagram for Burger::NetworkEndpointInstanceTCP:
Inheritance graph
[legend]
Collaboration diagram for Burger::NetworkEndpointInstanceTCP:
Collaboration graph
[legend]

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.
 
NetworkModuleGetNetworkModule (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

NetworkEndpointInstancem_pNextEndpointInstance
 Linked list of attached sockets.
 
NetworkEndpointInstancem_pParentInstance
 Set to point to a parent socket if this is a child.
 
CallbackProc m_pCallback
 Callback for this instance.
 
voidm_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
 
NetworkEndpointInstanceTCPoperator= (const NetworkEndpointInstanceTCP &)=delete
 
 NetworkEndpointInstanceTCP (NetworkEndpointInstanceTCP &&)=delete
 
NetworkEndpointInstanceTCPoperator= (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
NetworkModulem_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)
 

Constructor & Destructor Documentation

◆ NetworkEndpointInstanceTCP() [1/3]

Burger::NetworkEndpointInstanceTCP::NetworkEndpointInstanceTCP ( const NetworkEndpointInstanceTCP & )
privatedelete

◆ NetworkEndpointInstanceTCP() [2/3]

Burger::NetworkEndpointInstanceTCP::NetworkEndpointInstanceTCP ( NetworkEndpointInstanceTCP && )
privatedelete

◆ NetworkEndpointInstanceTCP() [3/3]

Burger::NetworkEndpointInstanceTCP::NetworkEndpointInstanceTCP ( NetworkModule * pNetworkModule)

◆ ~NetworkEndpointInstanceTCP()

virtual Burger::NetworkEndpointInstanceTCP::~NetworkEndpointInstanceTCP ( )
virtual

Member Function Documentation

◆ AcceptConnection()

virtual eError Burger::NetworkEndpointInstanceTCP::AcceptConnection ( CallbackProc pCallback,
void * pContext,
void * pExtra )
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.

Parameters
pCallbackPointer to a callback function that will be called to determine if a connection should be accepted or rejected.
pContextPointer to a context for the callback function.
pExtraPointer to the Endpoint that issued this accept request.
Returns
Zero if no error, non-zero on error.

Implements Burger::NetworkEndpointInstance.

◆ Close()

virtual eError Burger::NetworkEndpointInstanceTCP::Close ( uint_t bOrderly)
virtual

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.

Parameters
bOrderlyTRUE if the socket is to close in an orderly fashion, FALSE if not.
Returns
Zero if no error, non-zero on error.

Implements Burger::NetworkEndpointInstance.

◆ CreateMatchingSockets()

static eError Burger::NetworkEndpointInstanceTCP::CreateMatchingSockets ( uintptr_t * pSockets,
const NetAddr_t * pAddress,
NetworkEndpoint::eOpenType uOpenType )
static

◆ HandleRead()

uint_t Burger::NetworkEndpointInstanceTCP::HandleRead ( eSocketIndexes uIndex)

◆ IsAlive()

virtual uint_t Burger::NetworkEndpointInstanceTCP::IsAlive ( void )
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.

Returns
TRUE if there is an active connection to a remote endpoint.

Implements Burger::NetworkEndpointInstance.

◆ operator=() [1/2]

NetworkEndpointInstanceTCP & Burger::NetworkEndpointInstanceTCP::operator= ( const NetworkEndpointInstanceTCP & )
privatedelete

◆ operator=() [2/2]

NetworkEndpointInstanceTCP & Burger::NetworkEndpointInstanceTCP::operator= ( NetworkEndpointInstanceTCP && )
privatedelete

◆ Poll()

virtual eError Burger::NetworkEndpointInstanceTCP::Poll ( void )
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.

Returns
Zero if no error, non-zero on error.

Implements Burger::NetworkEndpointInstance.

◆ ProcessSocket()

void Burger::NetworkEndpointInstanceTCP::ProcessSocket ( eSocketIndexes uIndex,
void * pInputSet,
void * pOutputSet,
void * pExecSet )

◆ Receive()

virtual eError Burger::NetworkEndpointInstanceTCP::Receive ( uintptr_t * pBytesReceived,
void * pData,
uintptr_t uDataSize )
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.

Parameters
pBytesReceivedPointer to a value that will obtain the number of bytes received during this call.
pDataPointer to a data buffer to hold the received data.
uDataSizeSize of the buffer that will hold the received data.
Returns
Zero if no error, non-zero on error.
See also
ReceiveDatagram(uintptr_t *,const void *,uintptr_t)

Implements Burger::NetworkEndpointInstance.

◆ ReceiveData()

eError Burger::NetworkEndpointInstanceTCP::ReceiveData ( uintptr_t * pBytesReceived,
eSocketIndexes uIndex,
void * pData,
uintptr_t uDataSize )

◆ ReceiveDatagram()

virtual eError Burger::NetworkEndpointInstanceTCP::ReceiveDatagram ( uintptr_t * pBytesReceived,
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.

Parameters
pBytesReceivedPointer to a value that will obtain the number of bytes received during this call.
pDataPointer to a data buffer to hold the received data.
uDataSizeSize of the buffer that will hold the received data.
Returns
Zero if no error, non-zero on error.
See also
Receive(uintptr_t *,const void *,uintptr_t)

Implements Burger::NetworkEndpointInstance.

◆ RejectConnection()

virtual eError Burger::NetworkEndpointInstanceTCP::RejectConnection ( void * pExtra)
virtual

Reject a remote connection request.


Reject a connection to a remote endpoint.

Parameters
pExtraPointer to the Endpoint that issued an accept request that should be rejected.
Returns
Zero if no error, non-zero on error.

Implements Burger::NetworkEndpointInstance.

◆ Send()

virtual eError Burger::NetworkEndpointInstanceTCP::Send ( uintptr_t * pBytesSent,
const void * pData,
uintptr_t uDataSize,
eBlockMode uMode = kNonBlocking )
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.

Parameters
pBytesSentPointer to a value that will obtain the number of bytes sent during this call.
pDataPointer to a data buffer to transmit.
uDataSizeNumber of bytes to transmit.
uModeEither kBlocking if this function should block until error or all data is send or kNonBlocking if the function should return as soon as possible.
Returns
Zero if no error, non-zero on error.
See also
SendDatagram(uintptr_t *,const void *,uintptr_t,eBlockMode)

Implements Burger::NetworkEndpointInstance.

◆ SendDatagram()

virtual eError Burger::NetworkEndpointInstanceTCP::SendDatagram ( uintptr_t * pBytesSent,
const void * pData,
uintptr_t uDataSize,
eBlockMode uMode = kNonBlocking )
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.

Parameters
pBytesSentPointer to a value that will obtain the number of bytes sent during this call.
pDataPointer to a data buffer to transmit.
uDataSizeNumber of bytes to transmit.
uModeEither kBlocking if this function should block until error or all data is send or kNonBlocking if the function should return as soon as possible.
Returns
Zero if no error, non-zero on error.
See also
Send(uintptr_t *,const void *,uintptr_t,eBlockMode)

Implements Burger::NetworkEndpointInstance.

◆ SendDatagramSocket()

void Burger::NetworkEndpointInstanceTCP::SendDatagramSocket ( void )

◆ SetTimeOut()

virtual eError Burger::NetworkEndpointInstanceTCP::SetTimeOut ( uint32_t uTimeout = kDefaultTimeout)
virtual

Set the endpoint instance time in milliseconds.


Set the timeout value for this endpoint instance in milliseconds.

Parameters
uTimeoutTimeout in milliseconds, 5 seconds is the default. kDefaultTimeout
Returns
Zero if no error, non-zero on error.
See also
kDefaultTimeout

Implements Burger::NetworkEndpointInstance.

◆ SetupSockets()

eError Burger::NetworkEndpointInstanceTCP::SetupSockets ( eSocketIndexes uIndex,
const NetAddr_t * pAddress,
NetworkEndpoint::eOpenType uOpenType,
const uintptr_t * pSockets )

◆ StartAdvertising()

virtual eError Burger::NetworkEndpointInstanceTCP::StartAdvertising ( void )
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.

Returns
Zero if no error, non-zero on error.
See also
StopAdvertising(void)

Implements Burger::NetworkEndpointInstance.

◆ StopAdvertising()

virtual eError Burger::NetworkEndpointInstanceTCP::StopAdvertising ( void )
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.

Returns
Zero if no error, non-zero on error.
See also
StartAdvertising(void)

Implements Burger::NetworkEndpointInstance.

◆ TransmitData()

eError Burger::NetworkEndpointInstanceTCP::TransmitData ( uintptr_t * pBytesSent,
eSocketIndexes uIndex,
const void * pData,
uintptr_t uDataSize,
eBlockMode uMode = NetworkEndpointInstance::kNonBlocking )

◆ WaitingForOpen()

eError Burger::NetworkEndpointInstanceTCP::WaitingForOpen ( void )

Member Data Documentation

◆ m_bActive

uint_t Burger::NetworkEndpointInstanceTCP::m_bActive

TRUE if the endpoint is active

◆ m_bAdvertising

uint_t Burger::NetworkEndpointInstanceTCP::m_bAdvertising

TRUE if the endpoint is advertising its existence

◆ m_bAlive

uint_t Burger::NetworkEndpointInstanceTCP::m_bAlive

TRUE if this endpoint is alive and connected elsewhere

◆ m_bCallbackSent

uint_t Burger::NetworkEndpointInstanceTCP::m_bCallbackSent[kSocketIndexCount]

TRUE if the datagram/stream has issued a callback

◆ m_bDynamicallyAssignedRemotePort

uint_t Burger::NetworkEndpointInstanceTCP::m_bDynamicallyAssignedRemotePort

TRUE if the port was to be dynamically assigned

◆ m_bFlowsBlocked

uint_t Burger::NetworkEndpointInstanceTCP::m_bFlowsBlocked[kSocketIndexCount]

TRUE if the datagram/stream is blocked

◆ m_bIsDying

uint_t Burger::NetworkEndpointInstanceTCP::m_bIsDying

TRUE if this endpoint is in the process of shutting down

◆ m_bKillMe

uint_t Burger::NetworkEndpointInstanceTCP::m_bKillMe

TRUE if this endpoint should shut down

◆ m_bListening

uint_t Burger::NetworkEndpointInstanceTCP::m_bListening

TRUE if the endpoint is listening for data

◆ m_bPassiveMode

uint_t Burger::NetworkEndpointInstanceTCP::m_bPassiveMode

TRUE Enable passive mode

◆ m_GameName

String Burger::NetworkEndpointInstanceTCP::m_GameName

Name of the game owning this endpoint.

◆ m_pCallback

CallbackProc Burger::NetworkEndpointInstanceTCP::m_pCallback

Callback for this instance.

◆ m_pCallbackContext

void* Burger::NetworkEndpointInstanceTCP::m_pCallbackContext

Context for this instance.

◆ m_pNextEndpointInstance

NetworkEndpointInstance* Burger::NetworkEndpointInstanceTCP::m_pNextEndpointInstance

Linked list of attached sockets.

◆ m_pParentInstance

NetworkEndpointInstance* Burger::NetworkEndpointInstanceTCP::m_pParentInstance

Set to point to a parent socket if this is a child.

◆ m_uError

eError Burger::NetworkEndpointInstanceTCP::m_uError

Error state.

◆ m_uGameID

uint32_t Burger::NetworkEndpointInstanceTCP::m_uGameID

GameID this endpoint belongs to.

◆ m_uSocketFlags

eSocketFlags Burger::NetworkEndpointInstanceTCP::m_uSocketFlags

Datagram/stream desired.

◆ m_uSockets

uintptr_t Burger::NetworkEndpointInstanceTCP::m_uSockets[kSocketIndexCount]

Datagram and stream sockets.

◆ m_uTimeOut

uint32_t Burger::NetworkEndpointInstanceTCP::m_uTimeOut

Timeout value.

◆ m_uValidEndpoints

eSocketFlags Burger::NetworkEndpointInstanceTCP::m_uValidEndpoints

Datagram/stream valid.