Thanks,
Ed
Andy
Ed Jensen <eje...@visi.com> wrote in message
9F_W2.2376$WA4.4...@ptah.visi.com...
As far as I can tell, there isn't anything quite the same. Perhaps other
Windows experts can help out here, so I'll briefly describe socketpair()
and how one might use it.
socketpair() returns a pair of file descriptors (in Win32 that would be
file HANDLEs) for a full duplex pipe (in Unix, pipe() originally created
a half-duplex communication channel; many implementations now just
return a socketpair()).
The interesting thing is that a socketpair(), like a Unix pipe(), is
initially connected from the process to the kernel and then back to
itself. You might, for example, use this to translate non-socket events
to socket ones. This allows one location in your application to use
select()/poll() to dispatch.
I've been looking into this briefly. On my FreeBSD machine socketpair()
is
only implemented for the UNIX (aka LOCAL) address family (which is
really
the only one that makes sense anyway). This address family is of course
not
supported on Windows (WSAEnumProtocols() on my Win98 machine only lists
the
INET family) and consequently there's no socketpair() (or equivalent)
call
either.
I suppose you can get the same effect using a named pipe. The problem
is,
there is no way to simultaneously select on sockets and pipes. I would
love it if someone could prove me wrong on this. I guess you're supposed
to
convert the select() to asyncronous read/write calls, but that makes it
such
a drag trying to maintain a common code base across Windows and Unix...
/r
--
Rickard Lind, ri...@tutus.se
The only way I have found is to actually create
two sockets and connect them. You can accomplish
this through an ugly hack:
1. Create a socket, bind it to 127.0.0.1 and
a random port, and listen.
2. Spawn a thread that creates the second socket
and connects it to the same address and port.
3. Do an accept from the main thread.
4. Wait for the thread to exit and return the two
sockets.
If someone knows of a better way I'd sure like to know.
someday someone could implement the UNIX family of addresses on NT with the
WS2 SPI..
andy
Rickard Lind <ri...@tutus.se> wrote in message 37331617...@tutus.se...