This is the mail archive of the
cygwin-patches
mailing list for the Cygwin project.
RE: Open sockets non-overlapped?
- From: "Dave Korn" <dave dot korn at artimi dot com>
- To: <cygwin-patches at cygwin dot com>
- Date: Fri, 19 May 2006 16:56:50 +0100
- Subject: RE: Open sockets non-overlapped?
On 19 May 2006 16:20, Lev Bishop wrote:
> Here's a trivial little patch for your consideration (while I wait for
> my copyright assignment to go through).
>
> It makes it so that cygwin sockets can be passed usefully to windows
> processes. Eg:
> $ cmd /c dir > /dev/tcp/localhost/5001
> However, it's not perfect -- if the windows process just exits, then
> the connection is reset, not shut down gracefully.
Well, if the windows process just exits, that is exactly what it has done.
A socket should be shut down gracefully if the app calls shutdown(), and if it
just calls close() the socket should be reset. That's what "gracefully"
means.
> Playing with
> SO_LINGER doesn't seem to help here. Only way I can think of to make
> it work would be to have the cygwin stub that waits for windows
> processes to exit, to keep a handle on the socket, poll for when the
> windows process closes the socket (using NtQuerySystemInformation
> SystemHandleInformation?) and when it does, close down the socket
> gracefully.
It probably shouldn't be made to "work" because that would be altering the
semantics of sockets.
> Anyway, this adds new functionality and doesn't seem to break anything
> that worked before.
What, you've tested /everything/ that worked before? ;)
http://cygwin.com/ml/cygwin/2005-03/msg01003.html
------------------------quote------------------------
"If you create a socket using the Winsock 2 WSASocket API and you need to
apply a timeout in receive or send operations on the socket, you must
specify the WSA_FLAG_OVERLAPPED flag in the WSASocket call."
>From the MSDN website article
http://support.microsoft.com/default.aspx?scid=kb;en-us;181610.
------------------------quote------------------------
Are we /sure/ cygwin doesn't *depend* on overlapped sockets? In particular,
can a non-overlapped read be interrupted by a signal? Have you tested this
vs. both blocking and non-blocking sockets? This seems to me to be a highly
risky change; I'd like to know what testing you've done.
cheers,
DaveK
--
Can't think of a witty .sigline today....