in reply to What is the difference between udp client and server?
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: What is the difference between udp client and server?
by ikegami (Patriarch) on Nov 10, 2010 at 16:31 UTC |