A Multiplexed Psychiatrist Server
In this section we develop a version of the Chatbot::Eliza server that uses multiplexing. It illustrates how a typical multiplexed server works. The basic strategy for a multiplexed server follows this general outline:
Create a listen socket.
Create an IO::Select set and add the listen socket to the list of sockets to be monitored for reading.
Enter a select() loop.
When the select() loop returns, examine the list of sockets ready for reading. If the listen socket is among them, call accept() and add the resulting connected socket to the IO::Select set.
If other sockets are ready for reading, perform I/O on them.
As client connections finish, remove them from the IO::Select set.
This version of the Eliza server illustrates ...
Get Network Programming with Perl now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.