Muztaba Hasanat wrote:
So considering the simplest chat program that is two clients in two pc. This two clients have to implement ServerSocket in both end and they are listening each other for connection request. Is this right ?
In a simple peer to peer setup, then yes, one of the clients have to implement the ServerSocket. The other one can just be an initiator, and make the connection request to the ServerSocket, which will accept the connections.
If you like, it is possible to make both sides be both an acceptor and initiator, but it is not required. In fact, this is common, as most peer to peer setups can get complicated, and it is easier, if any peer can initiate to any other peer.
Muztaba Hasanat wrote:
And if there is a server between this two clients then also those two clients have to implement ServerSocket for any connection request from server. Is this right ?
In theory, yes. In practice, this is not common. In general, with setup with a server, the server is generally the acceptor, and all clients are initiators (meaning no ServerSocket).
Henry