Subject: Re: [B20.1 Win95] Problem with socket() function call.
From: [email-masked] (Andrew M. Bishop)

22 Jan 1999 08:48:50 -0800
Message-ID: <[email-masked]>
References: <[email-masked]>
To: [email-masked]

Warren Young wrote:
> >Is there any reason that the socket() function call should return
> >EINPROGRESS?
> 
> WSAEINPROGRESS (the properly decorated Winsock version of this error code)
> means "a blocking call is in progress".  It's an older error code from the
> Winsock 1.1 and Win16 days when blocking meant that Winsock would run a
> small message pump so one blocked app would not halt the entire system.

> depending on the fact that under WinNT, socket handles are inherited by
> child processes by default.  Unfortunately, a bug in Windows 95 (which you
> indicate that you're running) causes this to not be true; see MS knowledge
> base article Q150523 for details.  I don't know if this was fixed in
> Windows 98.
> 
> I suppose Cygwin could work around this with the WSADuplicateSocket() (or
> duplicate_handle() as it's wrapped internally) call, but that'd be messy
> /plus ultra/.

Cygwin already duplicates the handles when they are created with the
socket() function.  This should make them inheritable by the child.

From looking at the supplied MS code in the knowledge base and the
code in the cygwin DLL I don't see that there is required to be any
more work.  The socket handle is the SOCKET value which is known in
the child because it was known in the parent.  The only problem seems
to be that the MS code says that the socket should be closed by the
parent *after* the child has exited and not before which is the UNIX
way.

> Anyway, the fix for your program is probably to do the WSADuplicateSocket
> stuff yourself or to upgrade to Windows NT.  

Upgrading to Windows NT is not an option since I am trying to port one
of my own UNIX programs to win95.

It is a proxy web server and mostly works on Windows 95.  The socket
inheritance *does* seem to work most of the time, there are just some
oddities at times, including this problem with socket() and also with
gethostbyname() if DNS is used.

-- 
Andrew.
----------------------------------------------------------------------
Andrew M. Bishop                             [email-masked]
                                      http://www.gedanken.demon.co.uk/
-
For help on using this list (especially unsubscribing), send a message to
"[email-masked]" with one line of text: "help".