Received: from hrndva-omtalb.mail.rr.com (hrndva-omtalb.mail.rr.com [71.74.56.123]) by krbdev.mit.edu (8.12.9) with ESMTP id m2LLb7HW025184; Fri, 21 Mar 2008 17:37:07 -0400 (EDT) Received: from www.secure-endpoints.com ([24.193.47.99]) by hrndva-omta02.mail.rr.com with ESMTP id <20080321213702.UAOX21550.hrndva-omta02.mail.rr.com@www.secure-endpoints.com> for ; Fri, 21 Mar 2008 21:37:02 +0000 Received: from [192.168.1.34] by secure-endpoints.com (Cipher TLSv1:RC4-MD5:128) (MDaemon PRO v9.6.5) with ESMTP id md50000083134.msg for ; Fri, 21 Mar 2008 17:39:46 -0400 X-Spam-Processed: www.secure-endpoints.com, Fri, 21 Mar 2008 17:39:46 -0400 (not processed: message from trusted or authenticated source) X-Mdptrlookup-Result: pass dns.ptr=cpe-24-193-47-99.nyc.res.rr.com (ip=24.193.47.99) (www.secure-endpoints.com) X-Mdhelolookup-Result: hardfail smtp.helo=[192.168.1.34] (does not match 24.193.47.99) (www.secure-endpoints.com) X-Authenticated-Sender: jaltman@secure-endpoints.com X-Return-Path: jaltman@mit.edu X-Envelope-From: jaltman@mit.edu X-Mdaemon-Deliver-To: rt@krbdev.mit.edu Message-ID: <47E42B1E.8010300@mit.edu> Date: Fri, 21 Mar 2008 15:39:42 -0600 From: Jeffrey Altman User-Agent: Thunderbird 2.0.0.12 (Windows/20080213) MIME-Version: 1.0 To: rt@krbdev.mit.edu Subject: Re: [krbdev.mit.edu #5925] Windows socket(...) returns SOCKET, not file handle References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Reply-To: jaltman@mit.edu RT-Send-Cc: X-RT-Original-Encoding: iso-8859-1 Content-Length: 872 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.