Introduction
Client-Server Connection using
ObjectOutputStream & ObjectInputStream in JAVA.
In Client/Server applications the server normally listens to a specific port
waiting for connection requests from a client.
When a connection request arrives, the client and the server establish a
dedicated connection to communicate.
During the connection process, the client is assigned a local port number and binds a socket to it.
The client talks to the server by writing to the socket and gets information
from the server by reading from it.
Similarly, the server gets a new local port number to communicate with the client.
The server also binds a socket to its local port and communicates with the client by reading from and writing to it.
The server uses a specific port dedicated only to listening for connection
requests from other clients. It can not use this specific port for communication with the clients.
The client and the server must agree on a protocol. They must agree on the
language of the information transferred back and forth through the socket.
The java.net package in the Java development environment provides the class
“Socket” which implements the client-side and the class “ServerSocket” class which implements the server-side of the two-way link.
Server side
Output