#!/usr/bin/perl use IO::Socket; use IO::Select; sub tcp_slurpout($$) { my $dsock = $_[0]; my $data = $_[1]; my $theselect = IO::Select->new($dsock); if($theselect->can_write()) { syswrite($dsock,$data); return; } print "PROBLEM_TO_SEND:end_slurpout\n"; } my $dsock = IO::Socket::INET->new(PeerAddr => '127.0.0.1', PeerPort => 5000, Proto => 'tcp'); die "Could not create socket: $!\n" unless $dsock; print "Connected.\n"; print readline($dsock)."\n"; for (my $i=0;$i<10;$i++) { print "x:$i\n"; tcp_slurpout($dsock,"POS:20,0\n"); print readline($dsock)."\n"; } for (my $i=0;$i<10;$i++) { print "y:$i\n"; tcp_slurpout($dsock,"POS:0,20\n"); print readline($dsock)."\n"; } for (my $i=0;$i<10;$i++) { print "x:$i\n"; tcp_slurpout($dsock,"POS:-20,0\n"); print readline($dsock)."\n"; } for (my $i=0;$i<10;$i++) { print "y:$i\n"; tcp_slurpout($dsock,"POS:0,-20\n"); print readline($dsock)."\n"; } print "fin.\n";