CRM64Pro GDK v0.80.0
A free cross-platform game development kit built on top of SDL 3.0
Loading...
Searching...
No Matches
CRM64Pro::NetTCPfinal

NetTCP class. More...

Classes

struct  NetIPAddress
 Network address information. More...
struct  ClientInfo
 Client information struct. More...
struct  TXBackpressure
 TX backpressure watermark configuration. More...

Public Types

using CoreServerCallback = Sint32(*)(void* pData, Sint32 iSize, Uint8 iSenderIdx, void* pUser)
 Authoritative server callback used to validate an incoming user packet.

Public Member Functions

bool info (Sint32 iMode=0) override
 Request NetTCP module information.
eNetResult init (eLogMode eLM)
 Initialize the NetTCP system.
eNetResult close ()
 Close the NetTCP system.
bool isServer () const
 Check if the server is running.
bool isClient () const
 Check if the client is running.
NetIPAddress getIP () const
 Get the IP address.
eNetResult getClientName (string &sClientName) const
 Get the client name.
bool setFeatures (eNetTCPFeature eNF, bool bEnable)
 Set advanced features.
eNetTCPFeature getFeatures () const
 Get advanced features.
eNetResult createServer (Uint16 iPort, const string &sPassword, bool bDedicated)
 Create a server.
eNetResult setCoreServerCallback (CoreServerCallback fnCallback, void *pUser=nullptr)
 Set a callback function into the server thread for handling data.
bool isServerClientNamed (Uint8 iSenderIdx, const string &sClientName) const
 Check the server-verified name of the client that sent a callback packet.
eNetResult connectTo (const string &sHost, Uint16 iPort, const string &sClient, const string &sPassword)
 Connect to a server.
eNetResult sendData (const void *pData, Sint32 iSize)
 Send a data package.
eNetMsg receiveData (void **ppData, Uint32 *iSize, Uint8 *pSenderIdx=nullptr)
 Receive a data package (non-blocking method).
eNetResult freeData (void *&pData)
 Free a received data package.
eNetResult requestServerClose ()
 Request server shutdown.
eNetResult requestClientClose ()
 Request local client disconnection.
eNetResult queryClientsInfo ()
 Request updated information for all connected clients.
eNetResult getClientsInfo (ClientInfo **ppClientInfo, Sint32 *iCount)
 Get the local client information snapshot.
eNetResult getPendingWrites (Uint32 *iBytes) const
 Query pending outgoing bytes on the local client stream socket.
eNetResult setTXBackpressure (Uint32 iHighWater, Uint32 iLowWater)
 Set TX backpressure watermarks used by the main-thread flush loops.
TXBackpressure getTXBackpressure () const
 Get TX backpressure watermarks currently used by NetTCP.
eNetResult setTimeout (Sint32 iMs)
 Set the connection timeout.
Sint32 getTimeout () const
 Get the connection timeout.
eNetResult setSimDelay (Sint32 iMs)
 Simulate added round-trip latency without slowing the client network loop.
Sint32 getSimDelay () const
 Get the simulated connection delay.

Detailed Description

NetTCP class.

Member Typedef Documentation

◆ CoreServerCallback

using CRM64Pro::NetTCP::CoreServerCallback = Sint32(*)(void* pData, Sint32 iSize, Uint8 iSenderIdx, void* pUser)

Authoritative server callback used to validate an incoming user packet.

Parameters
pDataMutable packet payload valid for the callback duration.
iSizePayload size in bytes.
iSenderIdxServer-derived index of the sending connection.
pUserOptional application pointer supplied to setCoreServerCallback().
Returns
0 to accept and redistribute the packet, or a non-zero value to deny it.