in reply to Simple TCP Server to output data
use strict; use IO::Socket; my $yahoo = IO::Socket::INET->new(Proto => "tcp", PeerPort => 80, PeerAddr => "www.yahoo.com", Timeout => 2000) || die "failed to connect\n"; my $req = "GET / HTTP/1.1\r\nHost: www.yahoo.com\r\n\r\n"; print $yahoo $req; my $count = 0; while (<$yahoo>) { print "packet count = ", ++ $count, ", and first 20 chars of the p +acket = ", substr($_, 0, 20), "\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Simple TCP Server to output data
by gnu@perl (Pilgrim) on Mar 18, 2003 at 13:50 UTC | |
by merlyn (Sage) on Mar 18, 2003 at 13:51 UTC |