packetstormer has asked for the wisdom of the Perl Monks concerning the following question:
I am trying to use Perl to create a simple socket client. It connects to a remote server and then sends some text then gets the server response then sends some more text etc. My problem is I can only get it to connect, send some text and show the servers reply. It won't continue to send and receive, the "Enter String to send" appears each time as per the loop but it doesn't send or recv anything to the server. Code below:
As I am still a beginner I am sure this is a silly error. Can anyone spot it? Thanksuse IO::Socket::INET; $socket = new IO::Socket::INET ( PeerAddr => '172.16.0.30', PeerPort => 6001, Proto => 'tcp', ) or die "Couldn't connect to Server\n"; while ($socket) { print "\nEnter a string to send to SIP: "; $string=<STDIN>; chomp($string); $socket->send($string."\n"); $socket->recv($data,1024); print $data; }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Socket recv?
by Illuminatus (Curate) on Mar 11, 2011 at 21:56 UTC | |
Re: Socket recv?
by Corion (Patriarch) on Mar 11, 2011 at 20:52 UTC | |
by tye (Sage) on Mar 12, 2011 at 04:50 UTC | |
by ikegami (Patriarch) on Mar 12, 2011 at 08:09 UTC | |
by packetstormer (Monk) on Mar 11, 2011 at 21:00 UTC | |
by Corion (Patriarch) on Mar 11, 2011 at 21:24 UTC | |
by packetstormer (Monk) on Mar 11, 2011 at 22:18 UTC | |
by Illuminatus (Curate) on Mar 11, 2011 at 23:57 UTC | |
by ikegami (Patriarch) on Mar 11, 2011 at 22:06 UTC | |
by Illuminatus (Curate) on Mar 11, 2011 at 21:48 UTC | |
by ikegami (Patriarch) on Mar 11, 2011 at 22:02 UTC |
Back to
Seekers of Perl Wisdom