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
35#define TCP_BUFFER_LENGTH 32
36
38typedef enum
39{
44
45typedef struct
46{
47 filestream m_fSocket;
48 string m_strBuffer[TCP_BUFFER_LENGTH];
51} tcpinfo_t;
52
58int TCP_Connect(tcpinfo_t *in, string path);
59
64
69int TCP_Send(tcpinfo_t *in, string msg);
70
74string TCP_Receive(tcpinfo_t *in);
75
79void TCP_Frame(tcpinfo_t *in);
80
85 // 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: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:35
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:41
@ STATE_DISCONNECTED
We're disconnected/unconnected.
Definition: tcp.h:40
@ STATE_CONNECTED
We're fully connected.
Definition: tcp.h:42
Definition: tcp.h:46
filestream m_fSocket
Definition: tcp.h:47
tcpstate_t m_iState
Definition: tcp.h:50
int m_iBufferLines
Definition: tcp.h:49