nitin1704 has asked for the wisdom of the Perl Monks concerning the following question:
So I made a simple UDP client and server using IO::Socket. The code is given below. The problem is that the server prints the message from client only when it ends with a newline. Is there a way to change this? I tried disabling output buffering on the client side, but that didn't work.
client.pl
use IO::Socket; use strict; use warnings; my $sock = IO::Socket::INET->new( Proto => 'udp', PeerPort => 23456, PeerAddr => '10.254.83.40', ) or die "Could not create socket: $!\n"; select($sock); $|=1; $sock->send("message from client") or die "Send error: $!\n";
server.pl
use IO::Socket; use strict; use warnings; my $server = IO::Socket::INET->new(LocalPort => 23456, Proto => 'udp') or die "Couldn't be a udp server on port 23456 +: $@\n"; my $MAX_TO_READ = 1024; my $datagram = ''; while($server->recv($datagram, $MAX_TO_READ)){ print $datagram; }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: UDP Server doesn't receive before newline
by choroba (Cardinal) on Dec 04, 2012 at 09:10 UTC | |
Re: UDP Server doesn't receive before newline
by zwon (Abbot) on Dec 05, 2012 at 02:17 UTC | |
by nitin1704 (Sexton) on Dec 05, 2012 at 04:25 UTC | |
by zwon (Abbot) on Dec 05, 2012 at 05:45 UTC | |
by nitin1704 (Sexton) on Dec 05, 2012 at 07:41 UTC |
Back to
Seekers of Perl Wisdom