Digital Paint Discussion Board
Development => Bugs, Feature Requests, and Feedback => Topic started by: jitspoe on December 14, 2007, 05:52:26 AM
-
So I go to make the latest build with trivial changes from what I was using before, and all of a sudden this crops up. When the server starts, I get the assertion failure -- last one in this function:
int InitUDP (void)
{
u_long ioctlflags = 1;
struct sockaddr_in claddress;
#ifdef WIN32
if (WSAStartup(MAKEWORD(1, 1), &g_winsockdata)) // todo: does linux need any special initialization?
{
assert(0);
}
#endif
hash_table_init(&g_hash_address, 0xff, gi.TagFree); // 1.902
memset(&claddress, 0, sizeof(claddress));
if ((g_socket = socket(AF_INET, SOCK_DGRAM, 0)) < 0) // UDP
{
assert(0);
return -1;
}
if (ioctlsocket(g_socket, FIONBIO, &ioctlflags) < 0) // make it non-blocking
{
assert(0);
}
claddress.sin_family = AF_INET;
claddress.sin_port = (rand() % 10000) + 6000;
claddress.sin_addr.s_addr = INADDR_ANY;
if (bind(g_socket, (const struct sockaddr *)&claddress, sizeof(claddress)) < 0)
{
claddress.sin_port = PORT_ANY;
if (bind(g_socket, (const struct sockaddr *)&claddress, sizeof(claddress)) < 0)
{
assert(0);
}
}
return 0;
}
I thought maybe something was sucking up all the ports, but a quick lsof showed that wasn't the case, and I could still get it to work with the old executable. The weird thing is, on my laptop, it works fine. I even tried uploading the code and compiling. About the only thing that changed was fixing the mapinfo files closing.
-
Made it a little more informative rather than just having an assertion:
ERROR: Game Error: Failed to bind socket (98 - Address already in use)
98 is the error code. I don't get it. Why would this suddenly stop working? The address is 0 ("any"). I haven't touched this code since the last build.
-
Ok, this makes even LESS sense. I went back and compiled an older version of the code and it's still having the issue. Yet when I run an old already-compiled version, it's fine.
Edit: Got it straightened out. For any address, it needed to be set to 0, not -1. Strange this didn't cause problems before.