TCP/IP Networking API.
More...
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.
◆ TCP_Connect()
int TCP_Connect |
( |
tcpinfo_t * |
in, |
|
|
string |
path |
|
) |
| |
Open a TCP socket connection.
- Parameters
-
in | Pointer to a tcpinfo_t struct to save state into. |
path | The address:port to which we should connect to. |
- Returns
- The descriptor for the newly opened socket. Will be below 0 if invalid.
◆ TCP_Disconnect()
Closes a TCP socket connection.
@parm in Pointer to a tcpinfo_t that is to be closed.
◆ TCP_Frame()
You want to run this every frame.
- Parameters
-
in | Pointer to an active TCP connection. |
◆ TCP_GetState()
Returns the tcpstate_t of a connection.
- Parameters
-
in | Pointer to an active TCP connection. |
◆ TCP_Receive()
Receive the latest message from a TCP connection.
- Parameters
-
in | Pointer to an active TCP connection. |
◆ TCP_Send()
Send a string buffer to a specified TCP connection.
- Parameters
-
in | Pointer to an active TCP connection. |
msg | The message to send to the TCP connection. |
◆ TCP_BUFFER_LENGTH
#define TCP_BUFFER_LENGTH 32 |
◆ 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.
|