/* Relay -- a tool to record and play Quake2 demos Copyright (C) 2000 Conor Davis This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. Conor Davis cedavis@planetquake.com */ #ifndef __NET_H #define __NET_H #ifdef WIN32 #include #else /* WIN32 */ #include #include #include #include #include #include #define closesocket close #define ioctlsocket ioctl #endif #include "q2defines.h" typedef unsigned int SOCKET; // default ports for client, server, and master #define PORT_MASTER 27900 #define PORT_CLIENT 27901 #define PORT_SERVER 27910 #define RELIABLE_FLAG 0x80000000 #define KEEPALIVE_TIME 1000 typedef struct { struct sockaddr_in addr; size_t in_seq; size_t in_bit; size_t in_reliable_seq; size_t out_seq; size_t out_bit; size_t out_reliable_seq; size_t keepalive_time; unsigned short qport; char pad[2]; } net_t; extern int UDP_Begin(); extern int UDP_End(); extern int UDP_OpenSocket(unsigned short *port); extern int UDP_CloseSocket(SOCKET sd); extern int UDP_Read(SOCKET sd, void *buf, size_t len, struct sockaddr_in *addr); extern int UDP_Write(SOCKET sd, void *buf, size_t len, struct sockaddr_in *addr); extern int UDP_Poll(SOCKET sd, qboolean *readable, qboolean *writeable, qboolean *errors, long msecs); extern char *UDP_AddrToString(struct sockaddr_in *addr); extern int UDP_AddrCompare(struct sockaddr_in *addr1, struct sockaddr_in *addr2); extern int UDP_SendConnectionless(SOCKET sd, void *buf, size_t len, struct sockaddr_in *addr); extern int UDP_SendUnreliable(SOCKET sd, void *buf, size_t len, net_t *net); extern int UDP_SendReliable(SOCKET sd, void *buf, size_t len, net_t *net); extern int UDP_ResendReliable(SOCKET sd, void *buf, size_t len, net_t *net); #endif // __NET_H