This is the mail archive of the cygwin@sources.redhat.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

"descriptor is a file, not a socket"


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@sources.redhat.com
Red Hat, Inc.
mailto:vinschen@redhat.com

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]