Client:use strict; use IO::Socket; my $sock = new IO::Socket::INET (LocalHost => 'localhost', LocalPort => 5004, Proto => 'tcp', Listen => 5, Reuse => 1 + ); die "Socket could not be created. Reason: $!" unless $sock; my ($new_sock, $buf); while ($new_sock = $sock->accept()) { print "Connection from ", $new_sock->peerhost, ": on port ", $new_s +ock->peerport,"\n"; print $new_sock "Hello from the server"; while (defined ($buf = <$new_sock>)) { print $buf; } } close ($sock);
use strict; use IO::Socket; my $line; my $socket = new IO::Socket::INET ( PeerAddr => 'localhost', PeerPort => '5004', Proto => 'tcp', ); die "Could not create socket: $!\n" unless $socket; $socket->recv($line, 80); print "$line"; print $socket "Hello from the Client!\n"; close($socket);
In reply to Re: Problems reading back from socket
by rupesh
in thread Problems reading back from socket
by planet_guru
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |