The Chat Client

We look at the client program first (Figure 19.2). It has four tasks. It accepts commands from the user and transmits them in the proper format to the chat server, and it accepts messages from the server and transforms them into human-readable output for the user.

Figure 19.2. The chat client

The client uses two dispatch tables to handle user commands and server events. %COMMANDS dispatches on commands typed by the user. Each key is the text of a command (e.g., " join "), and each value is an anonymous subroutine that is invoked when the command is issued. In most cases, the subroutine simply sends the appropriate event code ...

Get Network Programming with Perl now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.