On Tue, Jan 25, 2000 at 09:12:31AM -0800, Brian D. Moffet wrote:
> Okay, stupid question. socketpair returns 2 sockets which according to
> the man page are "indistinguishable". Does this mean that you can read and
> write to either socket pair?
Yes sir.
> pipe(2) returns 2 file descriptors, one of which is a read and one of
> which is a write fd. The other end flips these around, and data is not
> mixed up that way.
No, with a so-called bi-directional pipe, both ends are readable and writable,
but bidirectional pipes are only found on certain systems. A traditional UNIX
pipe is half duplex -- one way only. It's better to use socketpair() if you
want full-duplex behaviour. Systems that have socketpair() can implement
pipes using socketpair internally, so bidirectional pipes are usually just
crippled UNIX-domain sockets in disguise.
> Will socketpair allow one program to read and write to the same file
> descriptor (what I would call real "bi-directional")... Like you can do
> with a normal old socket?
Yes.
--
James Bailie
http://members.home.net/jazzturk/main.html
To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message