use IO::Socket qw(crlf); # now you can use CRLF constant
$|++; # non-buffered
####
# in server:
print $new_sock $_, CRLF;
# in client:
print $sock "Hello there", CRLF;
####
# server
use strict;
use IO::Socket qw(:crlf);
my $sock = new IO::Socket::INET (
LocalAddr => 'localhost',
LocalPort => 10000,
Proto => 'tcp',
Listen => 1,
Reuse => 1,
);
die "Could not create socket\n" unless $sock;
my $new_sock = $sock->accept();
while(<$new_sock>) {
print $new_sock $_, CRLF;
}
close($sock);
#------------------------------
# client
use strict;
use IO::Socket qw(:crlf);
my $sock = new IO::Socket::INET (
PeerAddr => 'localhost',
PeerPort => 10000,
Proto => 'tcp',
);
die "could not create socket\n" unless $sock;
print $sock "Hello there", CRLF;
print $sock->getline();
close($sock);