Hi All,
I am running Perl 5.002 on a DEC 2100 with OSF/1 v3.2. I compiled Perl
successfully using DEC C and ran h2ph without any error. However
something didn't seem right when I use socket call to try the
client/server sample below.
I got the following message for both the server and the client but line
3 in my Perl code is a blank line for both the client and the server.
I don't know what is happenning here. Have I missed out something in
the h2ph conversion process? Any help are greatly appreciated.
Sincerely,
Loi Huynh.
This is the MESSAGE:
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Scalar found where operator expected at (eval 58) line 3, near "*($p"
(Missing operator before $p?)
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Here is the sample SERVER:
#!/usr/bin/perl -w
require 'sys/socket.ph';
$port = 7011;
$sockaddr = 'S n a4 x8';
($name, $aliases, $proto) = getprotobyname('tcp');
($name, $aliases, $port) = getservbyname($port, 'tcp') unless $port =~
/^\d+$/;
$this = pack($sockaddr, &AF_INET, $port, "\0\0\0\0");
socket(S, &PF_INET, &SOCK_STREAM, $proto) || die "socket: $!";
bind(S, $this) || die "bind: $!";
listen(S, 5) || die "connect: $!";
select(S);
$| = 1;
select(STDOUT);
for (;;) {
print "Listening again\n";
accept(NS,S) || die $!;
($addr = accept(NS,S)) || die $!;
print "accept ok\n";
($af,$port,$inetaddr) = unpack($sockaddr,$addr);
_at_inetaddr = unpack('C4',$inetaddr);
print "$af $port _at_inetaddr\n";
while (<NS>) {
print;
}
}
Here is the sample CLIENT:
#!/usr/bin/perl
($them,$port) = _at_ARGV;
$port = 7011 unless $port;
$them = 'localhost' unless $them;
require 'sys/socket.ph';
$sockaddr = 'S n a4 x8';
chop($hostname = `hostname`);
($name, $aliases, $proto) = getprotobyname('tcp');
($name, $aliases, $port) = getservbyname($port, 'tcp')
unless $port =~ /^\d+$/;
($name, $aliases, $type, $len, $thisaddr) =
gethostbyname($hostname);
($name, $aliases, $type, $len, $thataddr) = gethostbyname($them);
$this = pack($sockaddr, &AF_INET, 0, $thisaddr);
$that = pack($sockaddr, &AF_INET, $port, $thataddr);
socket(S, &PF_INET, &SOCK_STREAM, $proto) || die "socket: $!";
bind(S, $this) || die "bind: $!";
connect(S, $that) || die "connect: $!";
select(S);
$| = 1;
select(STDOUT);
while (<STDIN>) {
print S;
}
--
~~~~~~~~~~~~~~~~~~~~~~o~0~o~~~~~~~~~~~~~~~~~~~~~~~
News Interactive (PH)+61-2-9288-3635
2 Holt Street Surry Hills (FX)+61-2-9288-3171
NSW Australia 2010 http://www.ni.com.au
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Received on Wed May 21 1997 - 12:25:10 NZST