in reply to Recieving reply from a socket

First thing first, your code won't even compile in its present state. Also, always use strict and use warnings.

Reworked and compiling code:

use strict; use warnings; use IO::Socket::INET; my $socket = IO::Socket::INET->new(PeerAddr => "localhost", PeerPort => 12323, Proto => 'tcp'); print $socket "Hi!"; print $socket "Aha, I see!"; $socket->close();

To read the replies, all you really need to do is read from the socket like any other file handle. You can use recv, or, more simply, my $response = <$socket>.

And just because it is a common issue, you might want to take a look at Suffering From Buffering.

Replies are listed 'Best First'.
Re^2: Recieving reply from a socket
by Anonymous Monk on Mar 19, 2009 at 15:14 UTC
    My code is hanging on this line: my $response = <$socket>; How come? Thanks.
        Does this mean the server is not repling? Hers my code -
        use strict; use warnings; use IO::Socket::INET; my $socket = IO::Socket::INET->new(PeerAddr => "localhost", PeerPort => 12323, Proto => 'tcp'); print $socket "Hi!"; my $response = <$socket>; print $response; $socket->close();