#!/usr/bin/perl #udpserver.pl use strict; use warnings; use IO::Socket::INET; $| = 1; # flush after every write my $socket = new IO::Socket::INET ( LocalPort => '5000', Proto => 'udp', ) or die "ERROR in Socket Creation : $!\n"; while(1){ $socket->recv(my $recieved_data,1024); my $peer_address = $socket->peerhost(); my $peer_port = $socket->peerport(); print "\n($peer_address , $peer_port) said : $recieved_data"; #send the data to the client at which the read/write operations done recently. $socket->send ("Server received '$recieved_data'. This is the SERVER response\n"); } $socket->close(); # We will never get here , but good practice to close