#!/usr/bin/perl use strict; use warnings; use IO::Socket::INET; my $port = 5000; my $IP = "127.0.0.1"; # flush after every write $| = 1; my $client_socket = new IO::Socket::INET ( PeerHost => $IP, Type => SOCK_DGRAM, PeerPort => $port, Proto => 'udp' ) or die "ERROR in Socket Creation: $@\n"; my $Peer_Port = $client_socket->peerport(); my $data_send = "Test!!!!!"; $client_socket->send( $data_send ) or die "Client error while sending: $!\n"; #read operation $client_socket->recv( my $data_rcv , 1024 ) or die "Client error while received: $!\n"; print "Received data: $data_rcv\n"; $client_socket->close();