[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl] PPE socket example



I'm having trouble running the socket example on page 241of PPE.
I get the folloowing error message :

# IO::Socket::INET: Bad hostname 'daytime.clock.org'
File
'MacPerl:MacPerl:Examples:Chapter_17_Network_Programming:0.Sockets.0.pl';
Line 9

The Pod says that it can be a hostname or and IP address. I've tried it on
my linux box and it fails in the same manner. Am I doing some thing wrong?
The code followes.


#!perl -w
use IO::Socket;
my($sock, $line, $cr, $lf, $crlf);

$cr = "\015";
$lf = "\012";
$/ = $crlf = "$cr$lf";

$sock = IO::Socket::INET->new(
  PeerAddr => 'daytime.clock.org',
  PeerPort => 'daytime(13)',
  Proto    => 'tcp'
) or die($@);

while (defined($line = <$sock>)) {
  $line =~ s/$cr?$lf/$cr/g;
  print $line;
}


			Doug Spore



===== Want to unsubscribe from this list?
===== Send mail with body "unsubscribe" to macperl-request@macperl.org