Answer to Question #168877 in Java | JSP | JSF for Agnès Duhamel

Question #168877

What are the di±erences of handling Socket and ServerSocket ?


1
Expert's answer
2021-03-05T01:10:21-0500

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.


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog