| Simple Perl Client |
file.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use strict;
use Socket;
my $host = shift || 'localhost';
print "Input the port to which you would like to connectn";
my $port = shift || <STDIN>;
chomp($port);
my $proto = getprotobyname('tcp');
my $iaddr = inet_aton($host);
my $paddr = sockaddr_in($port, $iaddr);
socket(SOCKET, PF_INET, SOCK_STREAM, $proto) or die "socket: $!n";
connect(SOCKET, $paddr) or die "connect: $!";
my $line;
while ($line = <SOCKET>) {
print "$linen";
}
close SOCKET or die "close: $!";
Parsed in 0.012 seconds, using GeSHi 1.0.8.6
Please Login to Post a Comment.
Rating is available to Members only.
Please login or register to vote.
Please login or register to vote.
No Ratings have been Posted.



