[krbdev.mit.edu #5925] Windows socket(...) returns SOCKET, not file handle

Jeffrey Altman via RT rt-comment at krbdev.mit.edu
Fri Mar 21 17:37:13 EDT 2008


Kevin Koch via RT wrote:
> sendto_kdc.c start_connection(...) calls socket(...).  
> 
> The returned SOCKET is treated as a file handle.
> 
> On Windows, the SOCKET is greater than FD_SETSIZE, so close is called.  
> The SOCKET is also greater than the number of file handles, so close 
> asserts.

(1) close() is a C Runtime Library function that only works on C RTL 
file descriptors.   closesocket() must be used for SOCKET returned by 
socket().

(2) FD_SETSIZE in winsock has no relation to the value of SOCKET 
handles.   FD_SETSIZE is the number of sockets that can be stored in an 
fd_set.  It is not a maximum bound on the value of the handle.

Arrays of FD_SETSIZE are not safe to use on Windows.  Alternative data 
structures must be designed that will work on all platforms including 
UNIX/Linux systems whose "ulimit -n" values are raised above FD_SETSIZE.






More information about the krb5-bugs mailing list