Essentially, what I would do, is loop through the number of servers you have, create a new IO::Socket object, make it non-blocking, and dispatch a 'connect' request for it. Since it's non-blocking, you won't know if the connect succeeded or not until later. Repeat this for all of your sockets, and then enter a select loop (via IO::Select).
Keep data you're planning on sending in a buffer for that socket, select for writing those sockets that have data waiting to go out, write that data, and drop from the buffer the amount of data that was written.
Select for reading all of your sockets, process incoming data (being careful to preserve partial lines for next time), send it to whatever socket's input buffer it should go, etc.
Perhaps someone else can provide links to a good tutorial on building something like this.
In addition, migrating to an event-based architecture (such as POE) might be useful as well. I suspect a lot of this is "built-in".
In reply to Re: Simultaneous writes and as-needed reads from sockets (or The State of Perl Threads...)
by Fastolfe
in thread Simultaneous writes and as-needed reads from sockets (or The State of Perl Threads...)
by deprecated
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |