#usr/bin/perl
use strict;
use warnings;
use IO::Socket;
$| = 1;
my $client;
my $socket= new IO::Socket::INET(
PerHost => '192.168.0.34',
PeerPort => '4500',
Proto => 'tcp',
);
die "Couln't open socket: $!" unless $socket;
#open ALERT, ">alerts" or die " Unable to open file alerts \n";
while(1)
{
print "Accepting Socket....\n";
$client = $socket->accept();
print "Socket Accepted:$client....\n";
my $addr = $client->peerhost();
my $port = $client->peerport();
print "Got Connection from \"$addr\" at port $port\n";
while(1)
{
$client->recv(my $rec,1024);
my $date = `date`;
# print ALERT "[ $date ] :$rec\n";
print "[ $date ] :$rec\n";
}
}
####
Accepting Socket....
Use of uninitialized value in concatenation (.) or string at servertest.pl line 18.
Socket Accepted:....
Can't call method "peerhost" on an undefined value at servertest.pl line 19.
####
[root@station34 Socket]# telnet 192.168.0.34 4500
Trying 192.168.0.34...
Connected to station34 (192.168.0.34).
Escape character is '^]'.
^]
telnet> quit
Connection closed.