Bug Tracker – Attachment #188: WinSock fixes for bug #587

View | Details | Raw Unified | Return to bug 587
Collapse All | Expand All

(-)common/i_net.cpp (-8 / +24 lines)
Lines 124-130 Link Here
124
void BindToLocalPort (SOCKET s, u_short wanted)
124
void BindToLocalPort (SOCKET s, u_short wanted)
125
{
125
{
126
	int v;
126
	int v;
127
	struct hostent* h;
128
	struct sockaddr_in address;
127
	struct sockaddr_in address;
129
	netadr_t na;
128
	netadr_t na;
130
129
Lines 152-158 Link Here
152
		v = bind (s, (sockaddr *)&address, sizeof(address));
151
		v = bind (s, (sockaddr *)&address, sizeof(address));
153
		
152
		
154
		// GhostlyDeath <July 3, 2010> -- Fallback to any address
153
		// GhostlyDeath <July 3, 2010> -- Fallback to any address
155
		if (address.sin_addr.s_addr != INADDR_ANY && (errno == EACCES || errno == EADDRNOTAVAIL))
154
#ifdef _WIN32
155
		errno = WSAGetLastError();
156
#endif
157
		
158
		if (address.sin_addr.s_addr != INADDR_ANY &&
159
#ifdef _WIN32
160
			(errno == WSAEACCES || errno == WSAEADDRNOTAVAIL)
161
#else
162
			(errno == EACCES || errno == EADDRNOTAVAIL)
163
#endif
164
			)
156
		{
165
		{
157
			Printf (PRINT_HIGH, "BindToLocalPort: %s\n", strerror(errno));
166
			Printf (PRINT_HIGH, "BindToLocalPort: %s\n", strerror(errno));
158
			next--;
167
			next--;
Lines 291-308 Link Here
291
                             NET_AdrToString (net_from));
300
                             NET_AdrToString (net_from));
292
             return false;
301
             return false;
293
        }
302
        }
294
295
        Printf (PRINT_HIGH, "NET_GetPacket: %s\n", strerror(errno));
296
		return false;
297
#else
303
#else
298
        if (errno == EWOULDBLOCK)
304
        if (errno == EWOULDBLOCK)
299
            return false;
305
            return false;
300
        if (errno == ECONNREFUSED)
306
        if (errno == ECONNREFUSED)
301
            return false;
307
            return false;
308
#endif
302
309
303
        Printf (PRINT_HIGH, "NET_GetPacket: %s\n", strerror(errno));
310
        Printf (PRINT_HIGH, "NET_GetPacket: %s\n", strerror(errno));
304
        return false;
311
		return false;
305
#endif
306
    }
312
    }
307
    net_message.setcursize(ret);
313
    net_message.setcursize(ret);
308
    SockadrToNetadr (&from, &net_from);
314
    SockadrToNetadr (&from, &net_from);
Lines 357-363 Link Here
357
363
358
	namelen = sizeof(address);
364
	namelen = sizeof(address);
359
	if (getsockname (net_socket, (struct sockaddr *)&address, &namelen) == -1)
365
	if (getsockname (net_socket, (struct sockaddr *)&address, &namelen) == -1)
360
        Printf (PRINT_HIGH, "NET_Init: getsockname:", strerror(errno));
366
	{
367
#ifdef _WIN32
368
		errno = errno = WSAGetLastError();
369
#endif
370
		Printf (PRINT_HIGH, "NET_Init: getsockname:", strerror(errno));
371
	}
361
372
362
	net_local_adr.port = address.sin_port;
373
	net_local_adr.port = address.sin_port;
363
374
Lines 775-781 Link Here
775
   net_socket = UDPsocket ();
786
   net_socket = UDPsocket ();
776
   BindToLocalPort (net_socket, localport);
787
   BindToLocalPort (net_socket, localport);
777
   if (ioctlsocket (net_socket, FIONBIO, &_true) == -1)
788
   if (ioctlsocket (net_socket, FIONBIO, &_true) == -1)
789
   {
790
#ifdef _WIN32
791
		errno = errno = WSAGetLastError();
792
#endif
778
       I_FatalError ("UDPsocket: ioctl FIONBIO: %s", strerror(errno));
793
       I_FatalError ("UDPsocket: ioctl FIONBIO: %s", strerror(errno));
794
   }
779
795
780
	// enter message information into message info structs
796
	// enter message information into message info structs
781
	InitNetMessageFormats();
797
	InitNetMessageFormats();

Return to bug 587