With UDP sockets, the server receves packets, and the client sends them
If you can get hold of a copy, then you should take a look at the examples in Perl Cookbook (O'Reilly). Otherwise, take a look at IO::Socket::INET in CPAN.Here is a quick example:
Client:
my $sendSock = IO::Socket::INET->new( 'Proto' => 'udp', 'PeerPort' => $udp_port, 'PeerAddr' => $hostname, ) or die("Error creating socket $!"); $sendSock->send($data) or die("Socket send error $!");
Server:
my $listenSock = IO::Socket::INET->new('LocalPort'=>$udp_port, 'Proto' +=>'udp'); my $readBuff; $listenSock->recv( $readBuff, $MAX_BYTES );
Note that the server above will block until some data is received.
In reply to Re: What is the difference between udp client and server?
by chrestomanci
in thread What is the difference between udp client and server?
by shekarkcb
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |