Guest User

Untitled

a guest
Jan 12th, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 0.52 KB | None | 0 0
  1. #!/usr/bin/perl
  2. #udpserver.pl
  3.  
  4. use IO::Socket::INET;
  5.  
  6. # flush after every write
  7. $| = 1;
  8.  
  9. my ($socket,$received_data);
  10.  
  11. #  we call IO::Socket::INET->new() to create the UDP Socket and bound
  12. # to specific port number mentioned in LocalPort and there is no need to provide
  13. # LocalAddr explicitly as in TCPServer.
  14. $socket = new IO::Socket::INET ({
  15. LocalPort => '5000',
  16. Proto => 'udp',
  17. });
  18.  
  19. while(1)
  20. {
  21. # read operation on the socket
  22. $socket->recv($recieved_data,1024);
  23.  
  24. say $recieved_data;
  25.  
  26. }
  27.  
  28. $socket->close();
Add Comment
Please, Sign In to add comment