Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

socketpair() in 2.2-960612-SNAP

0 views
Skip to first unread message

Bill Paul

unread,
Jun 20, 1996, 3:00:00 AM6/20/96
to

Daring to challenge the will of the almighty Leviam00se, Boris Lavrinovich
(kur...@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: wp...@ctr.columbia.edu | Center for Telecommunications Research
Home: wp...@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."
=============================================================================

Nate Williams

unread,
Jun 20, 1996, 3:00:00 AM6/20/96
to

[ Emailed to poster as well ]

In article <kurzaev-2106...@boris.macsimum.gamma.ru>,


Boris Lavrinovich <kur...@macsimum.gamma.ru> wrote:
>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.

Why should there be a /dev/unix device?

>Should I set any options in kernel to make it work? I did not find any.

It should work fine now. What does your code look like? I suspect you
are using some sort of non-portable Linuxism (is that a word?) that doesn't
exist on FreeBSD.


Nate
--
na...@sri.com | Research Engineer, SRI Intl. - Montana Operations
na...@trout.mt.sri.com | Loving life in God's country, the great state of
work #: (406) 449-7662 | Montana (all the crazies are now in jail 'cept us
home #: (406) 443-7063 | natives). - Fly fishing fanatic!

Boris Lavrinovich

unread,
Jun 21, 1996, 3:00:00 AM6/21/96
to

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.

Any help will be great.
Boris.


=============================================
Boris Lavrinovich
Macsimum, Ltd

119899 Moscow University Computer Center
Vorobiovy Gory Moscow Russia
Voice: (095) 939-2471 Fax: (095) 939-1022
Internet: bo...@macsimum.gamma.ru

Boris Lavrinovich

unread,
Jun 21, 1996, 3:00:00 AM6/21/96
to

In article <4qc13h$1...@helena.MT.net>, "Nate Williams"
<na...@sneezy.sri.com> wrote:

> In article <kurzaev-2106...@boris.macsimum.gamma.ru>,
> Boris Lavrinovich <kur...@macsimum.gamma.ru> wrote:

> >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.
>

> Why should there be a /dev/unix device?
>

> >Should I set any options in kernel to make it work? I did not find any.
>

> It should work fine now. What does your code look like? I suspect you
> are using some sort of non-portable Linuxism (is that a word?) that doesn't
> exist on FreeBSD.

Oh, I have found where the problem is. socketpair() system call actually
succeeded but returned the value of first descriptor in pair instead of 0.
This is strange because it conforms neither to man page nor to POSIX
specification.

So the code that tests return value not to be equal -1 will work, but code
that tests return value to be equal 0 won't. This is nor a big problem for
me, but I suppose it should be fixed.

0 new messages