6.6 repChatClient and repChatServer

This group is used interactively. Start repChatServer and then a number of instances of repChatClient. Each client will connect to the server, resulting in a star-shaped connection topology. One may interact with each of the clients, and the clients in turn interact with the server.

The fragment commandCategory is used to distinguish different types of commands. The command language is very simple: anything starting with the letter q is a Quit command, anything starting with an a is an Answer command, and anything starting with an A is an AnswerWait command. Anything else is a Default command. Enter commands as any piece of text at the prompt, ending with RETURN. Please note that leading whitespace is significant.

All commands are immediately forwarded to the server. Then, if the command was a Quit command, the client closes down the connection and terminates. If it was an Answer command, the client notifies the user of that fact by printing a message containing the sequence number of this Answer command. Some time later, the server will return an answer, and the sequence number of the answer makes it possible to match up outgoing requests with incoming answers. In case of an AnswerWait command, the client blocks until the answer from the server arrives. For Default commands, the contents are just echoed at the server.

For each command received, the server echoes the identification number of the client which sent that command and the contents of the command. You may wish to examine the source code in repChatServer to see how nonblockingScope enables the server to (semi-)simultaneously receive incoming messages, accept connections from new clients, and do other work.


Process Libraries - Reference Manual
© 1994-2002 Mjølner Informatics
[Modified: Friday October 20th 2000 at 14:22]