The following examples demonstrates how sockets are used with the IO::Socket::INET and IO::Select modules.
#!/usr/bin/env perl # # start the pump server (Labview) before this # script is started # use strict; use IO::Socket::INET; use IO::Select; my $host="131.169.215.XX"; my $port=2612; my $sock = IO::Socket::INET->new(PeerAddr => $host, PeerPort => $port, Proto => 'udp') || die "Failed to connect\n"; # Type => SOCK_STREAM) || die "Failed to connect\n"; my $s = new IO::Select(); $s->add( $sock); sub sendMsg { my ( $msg) = @_; my $buffer ; $sock->send( $msg); while( length( $buffer) == 0 || $s->can_read(0.1)) { $sock->recv( $buffer, 100); } print " rec: $buffer \n"; sleep(5); } sendMsg( "pumpfast"); close($sock);