1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
|
# Client use IO::Socket::INET;
$MySocket = new IO::Socket::INET->new(PeerPort=>5001,Proto=>'udp',PeerAddr=>'loc alhost');
$def_msg="Ready to send : "; print "\n",$def_msg; while($msg=<STDIN>) { chomp $msg; if($msg ne '') { print "\nSending '",$msg,"' ..."; if($MySocket->send($msg)){ print $def_msg; }
} else { # ferme la connexion si chaine vide $MySocket->send('EXIT'); exit 1; } } |