From owner-freebsd-hackers Tue Jan 25 10:53: 0 2000 Delivered-To: freebsd-hackers@freebsd.org Received: from overcee.netplex.com.au (overcee.netplex.com.au [202.12.86.7]) by hub.freebsd.org (Postfix) with ESMTP id C08971529D for ; Tue, 25 Jan 2000 10:52:50 -0800 (PST) (envelope-from peter@netplex.com.au) Received: from netplex.com.au (localhost [127.0.0.1]) by overcee.netplex.com.au (Postfix) with ESMTP id 422721C03; Wed, 26 Jan 2000 02:52:48 +0800 (WST) (envelope-from peter@netplex.com.au) X-Mailer: exmh version 2.1.1 10/15/1999 To: "Brian D. Moffet" Cc: freebsd-hackers@freebsd.org Subject: Re: Performance issue with rfork() and single socketpairs versus multiple socketpairs. In-Reply-To: Message from "Brian D. Moffet" of "Tue, 25 Jan 2000 09:12:31 PST." <200001251712.JAA41726@moffetimages.com> Date: Wed, 26 Jan 2000 02:52:48 +0800 From: Peter Wemm Message-Id: <20000125185248.422721C03@overcee.netplex.com.au> Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG "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