ashok.g has asked for the wisdom of the Perl Monks concerning the following question:
When I try to run this script I'm getting this output...#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"; } }
FYIAccepting Socket.... Use of uninitialized value in concatenation (.) or string at servertes +t.pl line 18. Socket Accepted:.... Can't call method "peerhost" on an undefined value at servertest.pl li +ne 19.
Am I missing something here?[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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Problem with Socket Programming Perl Script
by Anonyrnous Monk (Hermit) on Jan 24, 2011 at 09:45 UTC | |
by ashok.g (Beadle) on Jan 24, 2011 at 10:47 UTC | |
by Anonyrnous Monk (Hermit) on Jan 24, 2011 at 10:58 UTC | |
by tyingst (Initiate) on Feb 10, 2016 at 19:44 UTC | |
by ashok.g (Beadle) on Jan 24, 2011 at 11:07 UTC | |
by Anonyrnous Monk (Hermit) on Jan 24, 2011 at 11:12 UTC | |
| |
|
Re: Problem with Socket Programming Perl Script
by Anonymous Monk on Jan 24, 2011 at 09:46 UTC |