net.h

Go to the documentation of this file.
00001 
00005 /*
00006 Copyright (C) 2002-2010 UFO: Alien Invasion.
00007 
00008 This program is free software; you can redistribute it and/or
00009 modify it under the terms of the GNU General Public License
00010 as published by the Free Software Foundation; either version 2
00011 of the License, or (at your option) any later version.
00012 
00013 This program is distributed in the hope that it will be useful,
00014 but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00016 
00017 See the GNU General Public License for more details.
00018 
00019 You should have received a copy of the GNU General Public License
00020 along with this program; if not, write to the Free Software
00021 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00022 
00023 */
00024 
00025 #ifndef _COMMON_NET_H
00026 #define _COMMON_NET_H
00027 
00028 struct net_stream;
00029 struct datagram_socket;
00030 struct sockaddr;
00031 typedef void stream_callback_func(struct net_stream *s);
00032 typedef void datagram_callback_func(struct datagram_socket *s, const char *buf, int len, struct sockaddr *from);
00033 
00034 qboolean SV_Start(const char *node, const char *service, stream_callback_func *func);
00035 void SV_Stop(void);
00036 
00037 struct datagram_socket *NET_DatagramSocketNew(const char *node, const char *service, datagram_callback_func *datagram_func);
00038 void NET_DatagramSend(struct datagram_socket *s, const char *buf, int len, struct sockaddr *to);
00039 void NET_DatagramBroadcast(struct datagram_socket *s, const char *buf, int len, int port);
00040 void NET_DatagramSocketClose(struct datagram_socket *s);
00041 void NET_SockaddrToStrings(struct datagram_socket *s, struct sockaddr *addr, char *node, size_t nodelen, char *service, size_t servicelen);
00042 
00043 void NET_Init(void);
00044 void NET_Shutdown(void);
00045 void NET_Wait(int timeout);
00046 struct net_stream *NET_Connect(const char *node, const char *service);
00047 struct net_stream *NET_ConnectToLoopBack(void);
00048 void NET_StreamEnqueue(struct net_stream *s, const char *data, int len);
00049 qboolean NET_StreamIsClosed(struct net_stream *s);
00050 int NET_StreamGetLength(struct net_stream *s);
00051 int NET_StreamPeek(struct net_stream *s, char *data, int len);
00052 int NET_StreamDequeue(struct net_stream *s, char *data, int len);
00053 void *NET_StreamGetData(struct net_stream *s);
00054 void NET_StreamSetData(struct net_stream *s, void *data);
00055 const char *NET_StreamPeerToName(struct net_stream *s, char *dst, int len, qboolean appendPort);
00056 qboolean NET_StreamIsLoopback(struct net_stream *s);
00057 void NET_StreamFree(struct net_stream *s);
00058 void NET_StreamFinished(struct net_stream *s);
00059 void NET_StreamSetCallback(struct net_stream *s, stream_callback_func *func);
00060 
00061 #endif

Generated by  doxygen 1.6.2