From f77435313179355cb5036c9150ab243788ed73b1 Mon Sep 17 00:00:00 2001 From: molivier Date: Wed, 11 Dec 2002 17:51:31 +0000 Subject: [PATCH] Some stupid Linux machines (i.e. Mandrake) seem to ignore their own network properties; in this case, we use the loopback address as the default one. Also, fixed an inoffensive bug when binding the UDP control socket. git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@2681 d7cf8633-e32d-0410-b094-e92efae38249 --- net_udp.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/net_udp.c b/net_udp.c index baf0ac4a..bd4a5de6 100644 --- 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); -- 2.39.2