From: havoc Date: Sat, 26 Apr 2003 10:03:42 +0000 (+0000) Subject: cleaned up UDP_Init a bit X-Git-Tag: xonotic-v0.1.0preview~6648 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=8bd8930c15240957499b14d3ff46703a6477687a;p=xonotic%2Fdarkplaces.git cleaned up UDP_Init a bit git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@2987 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/net_udp.c b/net_udp.c index 46f638c5..353fc7be 100644 --- a/net_udp.c +++ b/net_udp.c @@ -78,10 +78,6 @@ int UDP_Init (void) net_controlsocket = -1; for (j = 0;net_controlsocket == -1;j++) { - myAddr.d[0] = 127; - myAddr.d[1] = 0; - myAddr.d[2] = 0; - myAddr.d[3] = 1; switch(j) { case 0: @@ -98,7 +94,11 @@ int UDP_Init (void) local = gethostbyname(buff); if (local != NULL) myAddr.i = *((int *)local->h_addr_list[0]); + else + continue; } + else + continue; break; default: Con_Printf("UDP_Init: Giving up, UDP networking support disabled.\n"); @@ -108,20 +108,19 @@ int UDP_Init (void) return -1; } - if (myAddr.i != htonl(INADDR_LOOPBACK)) - { - if (myAddr.i == htonl(INADDR_LOOPBACK)) - sprintf(my_tcpip_address, "INADDR_LOOPBACK"); - else if (myAddr.i == htonl(INADDR_ANY)) - sprintf(my_tcpip_address, "INADDR_ANY"); - else - sprintf(my_tcpip_address, "%d.%d.%d.%d", myAddr.d[0], myAddr.d[1], myAddr.d[2], myAddr.d[3]); - Con_Printf("UDP_Init: Binding to IP Interface Address of %s... ", my_tcpip_address); - if ((net_controlsocket = UDP_OpenSocket (0)) == -1) - Con_Printf("failed\n"); - else - Con_Printf("succeeded\n"); - } + if (myAddr.i == htonl(INADDR_LOOPBACK)) + sprintf(my_tcpip_address, "INADDR_LOOPBACK"); + else if (myAddr.i == htonl(INADDR_ANY)) + sprintf(my_tcpip_address, "INADDR_ANY"); + else if (myAddr.i == htonl(INADDR_NONE)) + sprintf(my_tcpip_address, "INADDR_NONE"); + else + sprintf(my_tcpip_address, "%d.%d.%d.%d", myAddr.d[0], myAddr.d[1], myAddr.d[2], myAddr.d[3]); + Con_Printf("UDP_Init: Binding to IP Interface Address of %s... ", my_tcpip_address); + if ((net_controlsocket = UDP_OpenSocket (0)) == -1) + Con_Printf("failed\n"); + else + Con_Printf("succeeded\n"); } ((struct sockaddr_in *)&broadcastaddr)->sin_family = AF_INET;