"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?
Yep, you can write to either end and it will come out the other end.
> 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. One program cannot read and write to the same
> file descriptor, with the expectation that the two ends of the pipe will
> be able to properly communicate.
pipe(2) works the same way as socketpair on FreeBSD. As it does on SVR4
boxes (since 1989, including SCO Unixware and I believe Solaris).
> 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. socketpair(2) and pipe(2) are fully bidirectional. pipe(2) happens to
be a lot faster than the sockets based ones.
> Thanks
> Brian
>
> > > Use 'pipe(2)' rahter than 'socketpair(2)' as both are bidirectional and
> > > pipe is a LOT faster.
> >
> > Although pipe(2)'s bi-directional capabilities are not standard (I've
> > been stung by this in the past :-()
>
>
> To Unsubscribe: send mail to [EMAIL PROTECTED]
> with "unsubscribe freebsd-hackers" in the body of the message
>
>
Cheers,
-Peter
--
Peter Wemm - [EMAIL PROTECTED]; [EMAIL PROTECTED]; [EMAIL PROTECTED]
"All of this is for nothing if we don't go to the stars" - JMS/B5
To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message