Server/Client Networking at Java Platform
Socket programming furnishes the communication mechanism between the two systems using TCP. A client program itself makes a socket on its end of the communication and tries to connect that socket to a server. When the connection is made, the server creates an object of socket on its end of the communication. The client server can now easily communicate by writing to and reading from the socket. The java.net.Socket class represents a socket, and the java.net.ServerSocket class provides a mechanism for the server program to listen for clients and can make communication easily with them.