Writing a Talk Server / Talk Client using Java Sockets

Write a talk server and client using the Socket and ServerSocket classes provided in the java.net package. A ServerSocket listens on a certain port until it receives an incoming connection, when the ServerSocket manufactures a socket so the two ends of the connection can communicate. When two sockets have connected, they exchange data through InputStreams and OutputStreams which can be retrieved through the getInputStream() and getOutputStream() methods of the Socket class respectively. Since the InputStream and OutputStream classes can read and write only integers and byte arrays, the DataInputStream and DataOutputStream adapt the two to a more friendly interface.

Added Sophistication:

Script to run the socket demo


References

Flanagan, David; Java in a Nutshell, Section 7 on Networking
The Java tutorial is a useful online resource, especially the chapters networking overview and all about sockets.
Look at the Javasoft Java API Documentation on the java.net package and the java.io package.