Rx: Fix socket() handling so errors are properly detected
authorJeffrey Altman <jaltman@your-file-system.com>
Thu, 21 Oct 2010 18:23:18 +0000 (14:23 -0400)
committerJeffrey Altman <jaltman@openafs.org>
Sat, 23 Oct 2010 19:43:59 +0000 (12:43 -0700)
commitc8f47626e2428449bfb64844e46fe5ad6b8e0f1c
treec9eb402b8e7e3de6a8d60db3f242ebbde712ab01
parent046f230ed4dde4c31d849893eec750437135342e
Rx: Fix socket() handling so errors are properly detected

socket() returns an osi_socket which on Windows is an
unsigned type (HANDLE).  Therefore, tests of osi_socket < 0
will never identify when the INVALID_SOCKET value is returned.
On Windows, the OSI_NULLSOCKET is assigned to INVALID_SOCKET.
Replace all comparisons of (osi_socket < 0) with
(osi_socket == OSI_NULLSOCKET) as a means of detecting errors.

In addition, do not pass socket() the protocol value 0 when
IPPROTO_UDP is what is desired.

Finally, perror() on Windows never reports any error from Winsock.
perror() is a CRT function.  To get the real socket error
WSAGetLastError() must be called and its value be written to
stderr.

Change-Id: Ibc392eeb733851f56dbc7398cb252a4753b95275
Reviewed-on: http://gerrit.openafs.org/3027
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@openafs.org>
Tested-by: Jeffrey Altman <jaltman@openafs.org>
src/rx/rx_user.c
src/rxdebug/rxdebug.c