Une simple application client/serveur en Perl
Le serveur doit être allumé en premier
A simple client / server application in Perl
The server must be turned on first
Arabic
يجب تشغيل السيرفر أولا
Open in a new window
#!/usr/bin/perl ################################################# # find more codes on scrpts-n-codes.blogspot.com ################################################# # # this is server.pl ~ to turn on first ! # use IO::Socket; my $sock = new IO::Socket::INET ( LocalHost => 'localhost', LocalPort => '7070', Proto => 'tcp', Listen => 1, Reuse => 1, ); die "Could not create socket: $!\n" unless $sock; print "waiting for a message from the client ...\n"; my $new_sock = $sock->accept(); while(<$new_sock>) { print $_; } close($sock);
#!/usr/bin/perl ############################################################# # find more codes on scrpts-n-codes.blogspot.com ############################################################# # # this is client.pl ~ turn on server first ! # use IO::Socket; my $sock = new IO::Socket::INET ( PeerAddr => '127.0.0.1', PeerPort => '7070', Proto => 'tcp', ); die "Could not create socket: $!\n" unless $sock; print "Write the message to send to the serveur : "; $message=; print $sock $message; close($sock);