added winsock init/cleanup

This commit is contained in:
Chris Ison 2001-10-21 21:18:31 +00:00
parent 818f5de658
commit 6fd5239e52

View file

@ -123,7 +123,14 @@ UDP_Init (void)
char buff[MAXHOSTNAMELEN]; char buff[MAXHOSTNAMELEN];
struct qsockaddr addr; struct qsockaddr addr;
char *colon; char *colon;
#ifdef _WIN32
WSADATA winsockdata;
int r;
r = WSAStartup (MAKEWORD (1, 1), &winsockdata);
if (r)
Sys_Error ("Winsock initialization failed.");
#endif
if (COM_CheckParm ("-noudp")) if (COM_CheckParm ("-noudp"))
return -1; return -1;
@ -165,6 +172,7 @@ void
UDP_Shutdown (void) UDP_Shutdown (void)
{ {
UDP_Listen (false); UDP_Listen (false);
UDP_CloseSocket (net_controlsocket); UDP_CloseSocket (net_controlsocket);
} }
@ -222,7 +230,13 @@ UDP_CloseSocket (int socket)
{ {
if (socket == net_broadcastsocket) if (socket == net_broadcastsocket)
net_broadcastsocket = 0; net_broadcastsocket = 0;
#ifdef _WIN32
closesocket (socket);
WSACleanup ();
return 0;
#else
return close (socket); return close (socket);
#endif
} }
/* /*