sockets in PERL

HipCrime (HipCrime@HipCrime.com)
Thu, 31 Oct 1996 13:08:47 -0800


Currently writing a PERL proxy-server for ActiveAgent, so that
it will not be tied to those browsers which implement a liberal
Java security manager. Since applets are sometimes not allowed
to connect to URLs, one must provide a server-CGI to do it for
them.

My problem is getting a socket active in PERL. Never written it
before, and just can't make heads or tails of these Unix-system
calls. Does anybody know about this networking stuff?

Specifically, my code looks like:

$AF_INET = 2;
$SOCK_STREAM = 1;
$sock_addr = 'S n a4 x8';
(($name, $aliases, $proto) = getprotobyname('tcp')) ||
die "getprotobyname fail ($!): $name";

(($name, $aliases, $type, $len, $thataddr) =
gethostbyname($server_name)) ||
die "gethostbyname fail ($!): $server_name";

$that = pack($sockaddr, $AF_INET, $port, $thataddr);
socket(S, $AF_INET, $SOCK_STREAM, $proto) ||
die "socket fail ($!): $proto $server_name";

It takes the DIE on the socket call, with a message that the
TCP protocol is not supported. Obviously, this is a bit of
an obtuse question, but it seems like some of y'all are Unix
PERL-heads. Any ideas? BTW, had to run H2PH myself, and did
not know exactly what that did, but it seemed to create the
proper include files (PERL thought so, and used them).

... Robert