A client can send TCP and UDP messages using a socket, for example:
use IO::Socket;
my $socket = IO::Socket::INET->new(PeerAddr => 'theserver',
PeerPort => '1234', Proto => 'tcp', Type => SOCK_STREAM);
print $socket "Hello server!";
close($socket);
A server has to listen on a port, and accept messages that arrive on it:
my $socket = new IO::Socket::INET (LocalHost => 'hostname',
LocalPort => '1234', Proto => 'tcp', Listen => 1, Reuse => 1);
my $incoming = $sock->accept();
while(<$incoming>) {
print $_;
}
close($incoming);
This is just the tip of the iceberg, but hopefully this will help to get you started.