December 2000
Intermediate to advanced
784 pages
20h 54m
English
Despite the long introduction to threads, an actual multithreaded server is quite short. Here we develop a multithreaded version of the psychiatrist server (Figure 11.1).
Lines 1–5: Load modules We begin by loading IO::Socket and the Thread module. We also bring in a specialized version of Chatbot::Eliza in which the command_interface() method has been rewritten to work well in a multithreaded environment (Figure 11.2).
Figure 11.2. The Chatbot::Eliza::Server class
Lines 6–12: Create listening socket As in the previous examples, we create a new listening ...
Read now
Unlock full access