Nuclide
Software Development Kit for id Technology
tcp.h
1/*
2 * Copyright (c) 2016-2022 Vera Visions LLC.
3 *
4 * Permission to use, copy, modify, and distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
13 * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
14 * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15*/
16
36#define TCP_BUFFER_LENGTH 32
37
39typedef enum
40{
45
46typedef struct
47{
48 filestream m_fSocket;
49 string m_strBuffer[TCP_BUFFER_LENGTH];
52} tcpinfo_t;
53
59int TCP_Connect(tcpinfo_t *in, string path);
60
65
70int TCP_Send(tcpinfo_t *in, string msg);
71
75string TCP_Receive(tcpinfo_t *in);
76
80void TCP_Frame(tcpinfo_t *in);
81
86 // end of tcp
int TCP_Send(tcpinfo_t *in, string msg)
Send a string buffer to a specified TCP connection.
Definition: tcp.qc:44
tcpstate_t
State of a TCP connection.
Definition: tcp.h:40
tcpstate_t TCP_GetState(tcpinfo_t *in)
Returns the tcpstate_t of a connection.
Definition: tcp.qc:113
#define TCP_BUFFER_LENGTH
Definition: tcp.h:36
int TCP_Connect(tcpinfo_t *in, string path)
Open a TCP socket connection.
Definition: tcp.qc:18
void TCP_Frame(tcpinfo_t *in)
You want to run this every frame.
Definition: tcp.qc:74
string TCP_Receive(tcpinfo_t *in)
Receive the latest message from a TCP connection.
Definition: tcp.qc:63
void TCP_Disconnect(tcpinfo_t *in)
Closes a TCP socket connection.
Definition: tcp.qc:33
@ STATE_CONNECTING
We're in the process of connecting.
Definition: tcp.h:42
@ STATE_DISCONNECTED
We're disconnected/unconnected.
Definition: tcp.h:41
@ STATE_CONNECTED
We're fully connected.
Definition: tcp.h:43
Definition: tcp.h:47
filestream m_fSocket
Definition: tcp.h:48
tcpstate_t m_iState
Definition: tcp.h:51
int m_iBufferLines
Definition: tcp.h:50