[comp.lang.perl] anybody getting joy from socketpair

vixie@decwrl.dec.com (Paul A Vixie) (08/27/90)

This C program completes successfully:

	#define c(x) {int y=x; if (y) {printf("x returned %d\n", y); exit(1);}}
	main() {
		int sv[2];
		c(socketpair(1, 2, 0, sv));
		printf("sockets are %d, %d\n", sv[0], sv[1]);
		c(close(sv[0]));
		exit(0);
	}

This Perl program does not:

	#! /usr/local/bin/perl
	socketpair(f1, f2, 1, 2, 0) || die "socketpair: $!";
	print "fd's are ".fileno(f1).",".fileno(f2)."\n";
	close(f1) || die "close f1: $!";
	exit 0;

Does anybody know what I might be doing wrong?  As usual, I've dug myself
a hole and the ladder out is missing some rungs...  Ultrix pipes are not
based on sockets anymore and I need some socket-like pipes.

[vixie:vax] perl -v
$Header: perly.c,v 3.0.1.5 90/03/27 16:20:57 lwall Locked $
Patch level: 18
[...]

[vixie:vax] perl -
socketpair(f1, f2, 1, 2, 0) || die "socketpair: $!";
print "fd's are ".fileno(f1).",".fileno(f2)."\n";
close(f1) || die "close f1: $!";
exit 0;
fd's are 3,4
close f1: Bad file number at - line 2.
--
Paul Vixie
DEC Western Research Lab	<vixie@wrl.dec.com>
Palo Alto, California		...!decwrl!vixie

lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) (08/29/90)

In article <VIXIE.90Aug26203647@volition.pa.dec.com> vixie@decwrl.dec.com (Paul A Vixie) writes:
: This C program completes successfully:
: 
: 	#define c(x) {int y=x; if (y) {printf("x returned %d\n", y); exit(1);}}
: 	main() {
: 		int sv[2];
: 		c(socketpair(1, 2, 0, sv));
: 		printf("sockets are %d, %d\n", sv[0], sv[1]);
: 		c(close(sv[0]));
: 		exit(0);
: 	}
: 
: This Perl program does not:
: 
: 	#! /usr/local/bin/perl
: 	socketpair(f1, f2, 1, 2, 0) || die "socketpair: $!";
: 	print "fd's are ".fileno(f1).",".fileno(f2)."\n";
: 	close(f1) || die "close f1: $!";
: 	exit 0;
: 
: Does anybody know what I might be doing wrong?  As usual, I've dug myself
: a hole and the ladder out is missing some rungs...  Ultrix pipes are not
: based on sockets anymore and I need some socket-like pipes.

The socketpair call is working fine.  The only bug there is that close
is returning a faulty indication of failure.  It will be fixed in the
next patch.

Larry