Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 26 Jan 2000 02:52:48 +0800
From:      Peter Wemm <peter@netplex.com.au>
To:        "Brian D. Moffet" <brianm@moffetimages.com>
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: Performance issue with rfork() and single socketpairs versus multiple socketpairs. 
Message-ID:  <20000125185248.422721C03@overcee.netplex.com.au>
In-Reply-To: Message from "Brian D. Moffet" <brianm@moffetimages.com>  of "Tue, 25 Jan 2000 09:12:31 PST." <200001251712.JAA41726@moffetimages.com> 

next in thread | previous in thread | raw e-mail | index | archive | help
"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 majordomo@FreeBSD.org
> with "unsubscribe freebsd-hackers" in the body of the message
> 
> 

Cheers,
-Peter
--
Peter Wemm - peter@FreeBSD.org; peter@yahoo-inc.com; peter@netplex.com.au
"All of this is for nothing if we don't go to the stars" - JMS/B5



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20000125185248.422721C03>