Java Reference
In-Depth Information
Section 31.7
**31.9
( Chat ) Write a program that enables two users to chat. Implement one user
as the server (Figure 31.21a) and the other as the client (Figure 31.21b). The
server has two text areas: one for entering text and the other (noneditable) for
displaying text received from the client. When the user presses the Enter key,
the current line is sent to the client. The client has two text areas: one (nonedit-
able) for displaying text from the server and the other for entering text. When
the user presses the Enter key, the current line is sent to the server. Name the
client Exercise31_09Client and the server Exercise31_09Server.
(a)
(b)
F IGURE 31.21
The server and client send text to and receive text from each other.
***31.10
( Multiple client chat ) Write a program that enables any number of clients to
chat. Implement one server that serves all the clients, as shown in Figure 31.22.
Name the client Exercise31_10Client and the server Exercise31_10Server.
(a)
(b)
(c)
F IGURE 31.22
The server starts in (a) with three clients in (b) and (c).
 
 
Search WWH ::




Custom Search