What are the di±erences of handling Socket and ServerSocket ?
The ServerSocket object waits for a connection from the client (on the given port) using the accept () method, which blocks the current thread, when the client connects, it returns a Socket object that is used to communicate with the client.
The Socket object is trying to connect to the server (at the specified address / port), if the connection is successful, the further execution of the program simply occurs and the user can use the object's streams to communicate with the server, if the connection fails, an exception is thrown.
Comments
Leave a comment