Open sockets non-overlapped?
Lev Bishop
lev.bishop@gmail.com
Fri May 19 15:19:00 GMT 2006
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. 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.
Anyway, this adds new functionality and doesn't seem to break anything
that worked before.
2006-05-15 Lev Bishop <lev.bishop+cygwin@gmail.com>
* net.cc (cygwin_socket): Don't open socket for overlapped IO.
-------------- next part --------------
Index: cygwin/net.cc
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/net.cc,v
retrieving revision 1.206
diff -u -p -r1.206 net.cc
--- cygwin/net.cc 5 Apr 2006 16:53:12 -0000 1.206
+++ cygwin/net.cc 19 May 2006 04:24:05 -0000
@@ -578,7 +578,7 @@ cygwin_socket (int af, int type, int pro
debug_printf ("socket (%d, %d, %d)", af, type, protocol);
- soc = socket (AF_INET, type, af == AF_LOCAL ? 0 : protocol);
+ soc = WSASocket (AF_INET, type, af == AF_LOCAL ? 0 : protocol, 0, 0, 0);
if (soc == INVALID_SOCKET)
{
More information about the Cygwin-patches
mailing list