Simple server : Server « Network « Perl






Simple server

    

#!/usr/bin/perl
use warnings;
use strict;
use IO::Socket;
my $serv = IO::Socket::INET->new(LocalPort => 9876,Listen => 5); # queue up no more than 5 pending clients
while(my $client = $serv->accept()) { #somebody connected!
    print $client "The time is now: ".scalar(localtime(time()))."\n";
    close $client;
}

   
    
    
    
  








Related examples in the same category

1.Two way server
2.Time server
3.The server and the client are on the same machine
4.Socket answer
5.Socket pair
6.Socket server waiting for clients
7.Read from server
8.Send data from client to server
9.Forking Servers