Nuclide
Software Development Kit for id Tech
TCP/IP

TCP/IP Networking API. More...

Classes

struct  tcpinfo_t
 

Macros

#define TCP_BUFFER_LENGTH   32
 

Enumerations

enum  tcpstate_t { STATE_DISCONNECTED , STATE_CONNECTING , STATE_CONNECTED }
 State of a TCP connection. More...
 

Functions

int TCP_Connect (tcpinfo_t *in, string path)
 Open a TCP socket connection. More...
 
void TCP_Disconnect (tcpinfo_t *in)
 Closes a TCP socket connection. More...
 
int TCP_Send (tcpinfo_t *in, string msg)
 Send a string buffer to a specified TCP connection. More...
 
string TCP_Receive (tcpinfo_t *in)
 Receive the latest message from a TCP connection. More...
 
void TCP_Frame (tcpinfo_t *in)
 You want to run this every frame. More...
 
tcpstate_t TCP_GetState (tcpinfo_t *in)
 Returns the tcpstate_t of a connection. More...
 

Detailed Description

TCP/IP Networking API.

The TCP API manages the sending/receiving of data over TCP sockets.

First, establish a connection with TCP_Connect(), which will return a file descriptior. If TCP_Connect returns a value below 0, no connection is possible. You can send data through TCP_Send() once TCP_GetState returns STATE_CONNECTED.

You need to run TCP_Frame() on your tcpinfo_t struct every frame in order to listen to network activity.

Macro Definition Documentation

◆ TCP_BUFFER_LENGTH

#define TCP_BUFFER_LENGTH   32

Enumeration Type Documentation

◆ tcpstate_t

enum tcpstate_t

State of a TCP connection.

Enumerator
STATE_DISCONNECTED 

We're disconnected/unconnected.

STATE_CONNECTING 

We're in the process of connecting.

STATE_CONNECTED 

We're fully connected.

Function Documentation

◆ TCP_Connect()

int TCP_Connect ( tcpinfo_t in,
string  path 
)

Open a TCP socket connection.

Parameters
inPointer to a tcpinfo_t struct to save state into.
pathThe address:port to which we should connect to.
Returns
The descriptor for the newly opened socket. Will be below 0 if invalid.

◆ TCP_Disconnect()

void TCP_Disconnect ( tcpinfo_t in)

Closes a TCP socket connection.

@parm in Pointer to a tcpinfo_t that is to be closed.

◆ TCP_Frame()

void TCP_Frame ( tcpinfo_t in)

You want to run this every frame.

Parameters
inPointer to an active TCP connection.

◆ TCP_GetState()

tcpstate_t TCP_GetState ( tcpinfo_t in)

Returns the tcpstate_t of a connection.

Parameters
inPointer to an active TCP connection.

◆ TCP_Receive()

string TCP_Receive ( tcpinfo_t in)

Receive the latest message from a TCP connection.

Parameters
inPointer to an active TCP connection.

◆ TCP_Send()

int TCP_Send ( tcpinfo_t in,
string  msg 
)

Send a string buffer to a specified TCP connection.

Parameters
inPointer to an active TCP connection.
msgThe message to send to the TCP connection.