UFO: Alien Invasion
Loading...
Searching...
No Matches
net.h
Go to the documentation of this file.
1
4
5/*
6Copyright (C) 2002-2025 UFO: Alien Invasion.
7
8This program is free software; you can redistribute it and/or
9modify it under the terms of the GNU General Public License
10as published by the Free Software Foundation; either version 2
11of the License, or (at your option) any later version.
12
13This program is distributed in the hope that it will be useful,
14but WITHOUT ANY WARRANTY; without even the implied warranty of
15MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16
17See the GNU General Public License for more details.
18
19You should have received a copy of the GNU General Public License
20along with this program; if not, write to the Free Software
21Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22
23*/
24
25#pragma once
26
27class dbuffer;
28struct net_stream;
29struct datagram_socket;
30struct sockaddr;
31typedef void stream_onclose_func();
32typedef void stream_callback_func(struct net_stream* s);
33typedef void datagram_callback_func(struct datagram_socket* s, const char* buf, int len, struct sockaddr* from);
34
35bool SV_Start(const char* node, const char* service, stream_callback_func* func);
36void SV_Stop(void);
37
38struct datagram_socket* NET_DatagramSocketNew(const char* node, const char* service, datagram_callback_func* datagram_func);
39void NET_DatagramSend(struct datagram_socket* s, const char* buf, int len, struct sockaddr* to);
40void NET_DatagramBroadcast(struct datagram_socket* s, const char* buf, int len, int port);
42void NET_SockaddrToStrings(struct datagram_socket* s, struct sockaddr* addr, char* node, size_t nodelen, char* service, size_t servicelen);
43bool NET_ResolvNode(const char* node, char* buf, size_t bufLength);
44
45void NET_Init(void);
46void NET_Shutdown(void);
47void NET_Wait(int timeout);
48struct net_stream* NET_Connect(const char* node, const char* service, stream_onclose_func* onclose);
50void NET_StreamEnqueue(struct net_stream* s, const char* data, int len);
51int NET_StreamDequeue(struct net_stream* s, char* data, int len);
52void* NET_StreamGetData(struct net_stream* s);
53void NET_StreamSetData(struct net_stream* s, void* data);
54const char* NET_StreamPeerToName(struct net_stream* s, char* dst, int len, bool appendPort);
55const char* NET_StreamToString(struct net_stream* s);
56bool NET_StreamIsLoopback(struct net_stream* s);
57void NET_StreamFree(struct net_stream* s);
58void NET_StreamFinished(struct net_stream* s);
60
cvar_t * port
Definition common.cpp:58
voidpf void * buf
Definition ioapi.h:42
bool NET_StreamIsLoopback(struct net_stream *s)
Definition net.cpp:910
void SV_Stop(void)
Definition net.cpp:1026
void NET_StreamSetCallback(struct net_stream *s, stream_callback_func *func)
Definition net.cpp:903
dbuffer * NET_ReadMsg(struct net_stream *s)
Reads messages from the network channel and adds them to the dbuffer where you can use the NET_Read* ...
Definition net.cpp:774
void NET_Init(void)
Definition net.cpp:305
void NET_Shutdown(void)
Definition net.cpp:337
void NET_StreamEnqueue(struct net_stream *s, const char *data, int len)
Enqueue a network message into a stream.
Definition net.cpp:719
void NET_SockaddrToStrings(struct datagram_socket *s, struct sockaddr *addr, char *node, size_t nodelen, char *service, size_t servicelen)
Convert sockaddr to string.
Definition net.cpp:1212
void NET_StreamSetData(struct net_stream *s, void *data)
Definition net.cpp:805
bool SV_Start(const char *node, const char *service, stream_callback_func *func)
Definition net.cpp:990
void * NET_StreamGetData(struct net_stream *s)
Definition net.cpp:800
struct net_stream * NET_ConnectToLoopBack(stream_onclose_func *onclose)
Definition net.cpp:681
void stream_onclose_func()
Definition net.h:31
struct net_stream * NET_Connect(const char *node, const char *service, stream_onclose_func *onclose)
Try to connect to a given host on a given port.
Definition net.cpp:644
int NET_StreamDequeue(struct net_stream *s, char *data, int len)
Definition net.cpp:760
void NET_DatagramSend(struct datagram_socket *s, const char *buf, int len, struct sockaddr *to)
Definition net.cpp:1135
void NET_StreamFinished(struct net_stream *s)
Call NET_StreamFinished to mark the stream as uninteresting, but to finish sending any data in the bu...
Definition net.cpp:832
void NET_DatagramBroadcast(struct datagram_socket *s, const char *buf, int len, int port)
Definition net.cpp:1159
void NET_StreamFree(struct net_stream *s)
Call NET_StreamFree to dump the whole thing right now.
Definition net.cpp:817
void datagram_callback_func(struct datagram_socket *s, const char *buf, int len, struct sockaddr *from)
Definition net.h:33
void stream_callback_func(struct net_stream *s)
Definition net.h:32
const char * NET_StreamToString(struct net_stream *s)
Returns the numerical representation of a net_stream.
Definition net.cpp:859
bool NET_ResolvNode(const char *node, char *buf, size_t bufLength)
Definition net.cpp:1229
void NET_Wait(int timeout)
Definition net.cpp:423
void NET_DatagramSocketClose(struct datagram_socket *s)
Definition net.cpp:1182
const char * NET_StreamPeerToName(struct net_stream *s, char *dst, int len, bool appendPort)
Definition net.cpp:872
struct datagram_socket * NET_DatagramSocketNew(const char *node, const char *service, datagram_callback_func *datagram_func)
Opens a datagram socket (UDP).
Definition net.cpp:1102
QGL_EXTERN GLuint GLchar GLuint * len
Definition r_gl.h:99
QGL_EXTERN GLsizei const GLvoid * data
Definition r_gl.h:89
stream_onclose_func * onclose
Definition net.cpp:126
stream_callback_func * func
Definition net.cpp:127