Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 25 Jan 2000 17:47:28 -0500
From:      James Bailie <jazzturk@home.com>
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:  <20000125174727.A3649@cr31617-a.lndn1.on.wave.home.co>
In-Reply-To: <200001251712.JAA41726@moffetimages.com>; from brianm@moffetimages.com on Tue, Jan 25, 2000 at 09:12:31AM -0800
References:  <200001250124.BAA36765@hak.lan.Awfulhak.org> <200001251712.JAA41726@moffetimages.com>

next in thread | previous in thread | raw e-mail | index | archive | help
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 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?20000125174727.A3649>