1 /** 2 * @file 3 */ 4 5 /* 6 Copyright (C) 2002-2013 UFO: Alien Invasion. 7 8 This program is free software; you can redistribute it and/or 9 modify it under the terms of the GNU General Public License 10 as published by the Free Software Foundation; either version 2 11 of the License, or (at your option) any later version. 12 13 This program is distributed in the hope that it will be useful, 14 but WITHOUT ANY WARRANTY; without even the implied warranty of 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 17 See the GNU General Public License for more details. 18 19 You should have received a copy of the GNU General Public License 20 along with this program; if not, write to the Free Software 21 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 22 23 */ 24 25 #pragma once 26 27 class dbuffer; 28 struct net_stream; 29 struct datagram_socket; 30 struct sockaddr; 31 typedef void stream_onclose_func(); 32 typedef void stream_callback_func(struct net_stream *s); 33 typedef void datagram_callback_func(struct datagram_socket* s, const char* buf, int len, struct sockaddr* from); 34 35 bool SV_Start(const char* node, const char* service, stream_callback_func* func); 36 void SV_Stop(void); 37 38 struct datagram_socket* NET_DatagramSocketNew(const char* node, const char* service, datagram_callback_func *datagram_func); 39 void NET_DatagramSend(struct datagram_socket* s, const char* buf, int len, struct sockaddr* to); 40 void NET_DatagramBroadcast(struct datagram_socket* s, const char* buf, int len, int port); 41 void NET_DatagramSocketClose(struct datagram_socket* s); 42 void NET_SockaddrToStrings(struct datagram_socket* s, struct sockaddr* addr, char* node, size_t nodelen, char* service, size_t servicelen); 43 void NET_ResolvNode(const char* node, char* buf, size_t bufLength); 44 45 void NET_Init(void); 46 void NET_Shutdown(void); 47 void NET_Wait(int timeout); 48 struct net_stream *NET_Connect(const char* node, const char* service, stream_onclose_func* onclose); 49 struct net_stream *NET_ConnectToLoopBack(stream_onclose_func* onclose); 50 void NET_StreamEnqueue(struct net_stream *s, const char* data, int len); 51 int NET_StreamDequeue(struct net_stream *s, char* data, int len); 52 void* NET_StreamGetData(struct net_stream *s); 53 void NET_StreamSetData(struct net_stream *s, void* data); 54 const char* NET_StreamPeerToName(struct net_stream *s, char* dst, int len, bool appendPort); 55 const char* NET_StreamToString(struct net_stream *s); 56 bool NET_StreamIsLoopback(struct net_stream *s); 57 void NET_StreamFree(struct net_stream *s); 58 void NET_StreamFinished(struct net_stream *s); 59 void NET_StreamSetCallback(struct net_stream *s, stream_callback_func* func); 60 61 dbuffer* NET_ReadMsg(struct net_stream *s); 62