]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
Some stupid Linux machines (i.e. Mandrake) seem to ignore their own network propertie...
authormolivier <molivier@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 11 Dec 2002 17:51:31 +0000 (17:51 +0000)
committermolivier <molivier@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 11 Dec 2002 17:51:31 +0000 (17:51 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@2681 d7cf8633-e32d-0410-b094-e92efae38249

net_udp.c

index baf0ac4ab02cade1e02e54d67fea23bc2722458b..bd4a5de68e6f4dea1943ec8a3869890319859d27 100644 (file)
--- a/net_udp.c
+++ b/net_udp.c
@@ -64,7 +64,10 @@ int UDP_Init (void)
        // determine my name & address
        gethostname(buff, MAXHOSTNAMELEN);
        local = gethostbyname(buff);
-       myAddr = *(int *)local->h_addr_list[0];
+       if (!local)
+               myAddr = htonl(INADDR_LOOPBACK);  // default to the loopback address
+       else
+               myAddr = *(int *)local->h_addr_list[0];
 
        // if the quake hostname isn't set, set it to the machine name
        if (strcmp(hostname.string, "UNNAMED") == 0)
@@ -77,7 +80,7 @@ int UDP_Init (void)
                Sys_Error("UDP_Init: Unable to open control socket\n");
 
        ((struct sockaddr_in *)&broadcastaddr)->sin_family = AF_INET;
-       ((struct sockaddr_in *)&broadcastaddr)->sin_addr.s_addr = INADDR_BROADCAST;
+       ((struct sockaddr_in *)&broadcastaddr)->sin_addr.s_addr = htonl(INADDR_BROADCAST);
        ((struct sockaddr_in *)&broadcastaddr)->sin_port = htons(net_hostport);
 
        UDP_GetSocketAddr (net_controlsocket, &addr);