Nuclide
Software Development Kit for id Technology (BETA)
TCPHandler.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 string m_host;
53 string m_port;
54
58} tcpinfo_t;
59
65int TCP_Connect(tcpinfo_t *in, string path);
66
71
76int TCP_Send(tcpinfo_t *in, string msg);
77
81string TCP_Receive(tcpinfo_t *in);
82
86void TCP_Frame(tcpinfo_t *in);
87
92 // end of tcp
int TCP_Send(tcpinfo_t *in, string msg)
Send a string buffer to a specified TCP connection.
Definition: TCPHandler.qc:52
tcpstate_t
State of a TCP connection.
Definition: TCPHandler.h:40
tcpstate_t TCP_GetState(tcpinfo_t *in)
Returns the tcpstate_t of a connection.
Definition: TCPHandler.qc:143
#define TCP_BUFFER_LENGTH
Definition: TCPHandler.h:36
int TCP_Connect(tcpinfo_t *in, string path)
Open a TCP socket connection.
Definition: TCPHandler.qc:18
void TCP_Frame(tcpinfo_t *in)
You want to run this every frame.
Definition: TCPHandler.qc:103
string TCP_Receive(tcpinfo_t *in)
Receive the latest message from a TCP connection.
Definition: TCPHandler.qc:72
void TCP_Disconnect(tcpinfo_t *in)
Closes a TCP socket connection.
Definition: TCPHandler.qc:41
@ STATE_CONNECTING
We're in the process of connecting.
Definition: TCPHandler.h:42
@ STATE_DISCONNECTED
We're disconnected/unconnected.
Definition: TCPHandler.h:41
@ STATE_CONNECTED
We're fully connected.
Definition: TCPHandler.h:43
Definition: TCPHandler.h:47
string m_port
Definition: TCPHandler.h:53
float m_lastMessageSent
Definition: TCPHandler.h:56
float m_timeOfConnection
Definition: TCPHandler.h:55
filestream m_fSocket
Definition: TCPHandler.h:48
string m_host
Definition: TCPHandler.h:52
tcpstate_t m_iState
Definition: TCPHandler.h:51
int m_iBufferLines
Definition: TCPHandler.h:50
float m_lastMessageReceived
Definition: TCPHandler.h:57