A simple TCP server written in Perl

The below example is a very simple TCP server script written in Perl, which uses the AnyEvent module.
It will create a separate process for each connections and has the ability to return data to the parent process.
The below example allows 15 child processes to be created, which results in 15 simultaneous client connections.

The script itself is pretty straight-forward: it creates a server object using IO::Socket::INET and attaches that socket to an AnyEvent IO eventloop. Furthermore, upon every connection, it will call the subroutine fork_call (which is in the AnyEvent::Util module) to open up a client socket.


A simple TCP server written in Perl — 1 Comment

Leave a Reply

Your email address will not be published. Required fields are marked *