Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT sources DOT redhat DOT com Delivered-To: mailing list cygwin AT sources DOT redhat DOT com Message-ID: <39F80A9F.8FB0F0B2@redhat.com> Date: Thu, 26 Oct 2000 12:42:39 +0200 From: Corinna Vinschen Reply-To: cygwin X-Mailer: Mozilla 4.75 [en] (X11; U; Linux 2.2.14-SMP i686) X-Accept-Language: de, en MIME-Version: 1.0 To: cygwin Subject: "descriptor is a file, not a socket" Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To all those which had (or have) the problem mentioned in the subject: It took some time to track that down but I finally came to the following conclusion: For some reason there are systems (mostly 9x/ME, seldom NT) which flawed to duplicate a socket so that the duplicated socket isn't usable in further socket function calls. All those functions will then return WSAENOTSOCK. If you ask me how to determine the reason why a system has that problem: I don't know. I had the luck that one of my 9x/ME systems was broken but I couldn't figure out the reason. Anyway, the good news is, there's a way to work around that flaw. I'm now using special Winsock2 functions (WSADuplicateSocket/WSASocket) to duplicate the socket to the child process which is the recommended way for sharing sockets on Windows platforms. The disadvantage might be a slight (sigh) slow down on fork/exec if sockets are currently in use by the parent. The new method forces us to start the child process in SUSPEND state if one of the open file descriptors is a socket. Another problem rushes forward: 95 and NT3.51 systems don't have Winsock2. But that shouldn't be a problem. The old method is still part of Cygwin and if Cygwin fails to load the Winsock2 dll, the old method is used. I tested that on a 95 system so I'm quite sure. Nevertheless, 95 users might have the "descriptor is a file, not a socket" problem as well. What now? In this case you can download Winsock2 for 95 from Microsoft's web site for free (surprise!): http://www.microsoft.com/windows95/downloads/contents/wuadmintools/s_wunetworkingtools/w95sockets2/default.asp Check for existance of ws2_32.dll in your WINDOWS\system directory first. I'm not sure but probably you got it if you have downloaded some newer versions of IE or Outlook. However, note that 95/98 has a Winsock2 error, though. Excerpt from Microsoft KB article Q229658: "Windows Sockets version 2.0 does not deallocate a socket that has been duplicated [using WSADuplicateSocket()] if the Closesocket() function is called against the duplicated socket descriptor first, and then against the duplicate socket. Although the socket is ultimately deallocated when the process quits, overuse of socket resources may occur in the interim. Even after closing the socket at the program level, the socket provider may see a socket using that address." That shouldn't be a too heavy disadvantage, I hope. Ok, I have just checked in the patch so it's accessible via CVS already or it will be in the next developers snapshot. So, time to have a shower now! Have fun, Corinna -- Corinna Vinschen Please, send mails regarding Cygwin to Cygwin Developer mailto:cygwin AT sources DOT redhat DOT com Red Hat, Inc. mailto:vinschen AT redhat DOT com -- Want to unsubscribe from this list? Send a message to cygwin-unsubscribe AT sourceware DOT cygnus DOT com