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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access