Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl
- #udpserver.pl
- use IO::Socket::INET;
- # flush after every write
- $| = 1;
- my ($socket,$received_data);
- # we call IO::Socket::INET->new() to create the UDP Socket and bound
- # to specific port number mentioned in LocalPort and there is no need to provide
- # LocalAddr explicitly as in TCPServer.
- $socket = new IO::Socket::INET ({
- LocalPort => '5000',
- Proto => 'udp',
- });
- while(1)
- {
- # read operation on the socket
- $socket->recv($recieved_data,1024);
- say $recieved_data;
- }
- $socket->close();
Add Comment
Please, Sign In to add comment