Nuclide
Software Development Kit for id Tech
tcp.h
Go to the documentation of this file.
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
32#define TCP_BUFFER_LENGTH 32
33
35typedef enum
36{
41
42typedef struct
43{
45 string m_strBuffer[TCP_BUFFER_LENGTH];
48} tcpinfo_t;
49
55int TCP_Connect(tcpinfo_t *in, string path);
56
61
66int TCP_Send(tcpinfo_t *in, string msg);
67
71string TCP_Receive(tcpinfo_t *in);
72
76void TCP_Frame(tcpinfo_t *in);
77
#define filestream
Definition: fteextensions.qc:271
Definition: tcp.h:43
filestream m_fSocket
Definition: tcp.h:44
tcpstate_t m_iState
Definition: tcp.h:47
int m_iBufferLines
Definition: tcp.h:46
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:36
@ STATE_CONNECTING
We're in the process of connecting.
Definition: tcp.h:38
@ STATE_DISCONNECTED
We're disconnected/unconnected.
Definition: tcp.h:37
@ STATE_CONNECTED
We're fully connected.
Definition: tcp.h:39
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:32
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