*BSD News Article 71580


Return to BSD News archive

Path: euryale.cc.adfa.oz.au!newshost.anu.edu.au!harbinger.cc.monash.edu.au!news.mel.connect.com.au!news.mira.net.au!inquo!news.uoregon.edu!newsfeed.internetmci.com!news.msfc.nasa.gov!sol.ctr.columbia.edu!startide.ctr.columbia.edu!wpaul
From: wpaul@ctr.columbia.edu (Bill Paul)
Newsgroups: comp.unix.bsd.freebsd.misc
Subject: Re: socketpair() in 2.2-960612-SNAP
Date: 20 Jun 1996 14:03:22 GMT
Organization: Columbia University Center for Telecommunications Research
Lines: 48
Message-ID: <4qblnb$t7j@sol.ctr.columbia.edu>
References: <kurzaev-2106960147180001@boris.macsimum.gamma.ru>
NNTP-Posting-Host: startide.ctr.columbia.edu
X-Newsreader: TIN [version 1.2 PL2]

Daring to challenge the will of the almighty Leviam00se, Boris Lavrinovich
(kurzaev@macsimum.gamma.ru) had the courage to say:

: I installed 2.2-960612-SNAP and discovered that socketpair() system call
: returns "File exists" error in my programs. I used Linux before and
: suppose that there should be /dev/unix device but there is no such device.
: Should I set any options in kernel to make it work? I did not find any.

You may not be using it correctly. (It's hard to say: you didn't show
us an example of what you're doing with it.) There is no /dev/unix in
BSD. Nor is there a /dev/udp, /dev/tcp or other such things: those are
System V warts.

Here's a sample program that calls socketpair() to create two joined
descriptors:

#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <err.h>
#include <errno.h>

main()
{
        int sv[2];

        if (socketpair(AF_UNIX, SOCK_STREAM, 0, (int *)&sv) == -1) {
                err(1,"socketpair failed");
        }

        printf ("descriptor 1 is: [%d]\n", sv[0]);
        printf ("descriptor 2 is: [%d]\n", sv[1]);
        
        exit(0);
}

Note that you can achieve the same effect with pipe(2).

-Bill

--
=============================================================================
-Bill Paul            (212) 854-6020 | System Manager, Master of Unix-Fu
Work:         wpaul@ctr.columbia.edu | Center for Telecommunications Research
Home:  wpaul@skynet.ctr.columbia.edu | Columbia University, New York City
=============================================================================
 "If you're ever in trouble, go to the CTR. Ask for Bill. He will help you."
=============================================================================