One client per server is not too complicated - what you do with your code is efficient - creating relationships from 1 to 1. Your fork ed server works exclusively with your client.
In order to get information for distribution (through the server) between several clients, you will have to get a little complicated - because you have separate processes, now these processes must interact with each other. This is a pretty big question that there is a whole segment of perl: perlipc .
This will significantly increase the complexity of your code because you are moving to a one-to-many relationship in your messages, and they will all occur asynchronously.
Socket-based communication is a form of interprocess communication (IPC), and you already do it. But your "getcha" here is that you go from 1 to 1 comm. Up to 1 to many. You should be able to broadcast, and this method of communication does not support this particularly well.
What I would like to suggest, look at IO::Pipe - here is an example code: How to extract data from Parallel :: ForkManager in perl
Then use IO::Select and can_read to asynchronously decide if there is any data in the pipe. You will probably need an array of pipes β one for each customer β otherwise you may be matched with matching materials.
eg:.
(From IO::Pipe doc page:
my $pipe = IO::Pipe->new(); if($pid = fork()) {
Unfortunately, there is little information here: your pipes will be created by the forking process, but this, in turn, means that you need to figure out how to process the pipe array and check if they are available.
This means that you can no longer sit in the while with accepting sockets, which is blocked, so you will have message queues until the other client connects (which is really not the way you want). Therefore, you will also need to use select again to check if there is something ready for accept .