What is the difference between Socket and ServerSocket class in java.net package

Questions by questioninterest

Showing Answers 1 - 5 of 5 Answers


  • Nov 14th, 2006

Basic difference is that...ServerSocket is implemented on the server side ...so that it can listen the client requests and respond to them...and Socket is implemented at the client side..to send requests to the port of the machine where ServerSocket is listening

  Was this answer useful?  Yes


  • Nov 21st, 2006

Socket -> it is placed in client side, which sends request to server side socket(ServerSocket) and wait for the response from server...

ServerSocket -> it is placed in server side, which sends request to client side socket(Socket) and wait for the response from client...

it is just like connecting to medium(cliend and server), it is similar to electric plug

  Was this answer useful?  Yes

Thirunavukkarasu. C

  • Jan 19th, 2007

     Socket is nothing but collection of flug pointer in it..


            Its completely based on the client side..


           Its completely based on server side..

  Was this answer useful?  Yes


  • Feb 20th, 2007

difference b/w ServerSocket and Socket :

ServerSocket : 
                               /**Theoritacally speeking server is the one , which process the response for the request **/
                             Server is the one which keep on listening the port to process the request.Hence you need the port number .To saywhere it should listen we need to give the following line in the codeing.     

                                   ServerSocket ssoc = new ServerSocket(8000); // u can give ur own port number

Socket :
                     /** Theoritacally speaking client is the one which send the request to server and waiting for the response**/

                                Socket class is used to send the request to the server waiting for responses .To send the request we need the ip/hostname (address) of the server and the port in which it actually listening.
                                Socket soc = new Socket(,8000);

  Was this answer useful?  Yes

kritika jha

  • Jun 13th, 2009

Socket class is meant for client side, so in a client side
you need to make a object of Socket class for any networking application,
For server side networking application ServerSocket class is used, in this class method named as serversocket_object.accept() is used by server to listen to clients at specific port addresses, for local computer it is either "localhost" or "" and might be
your subnet address in case of some LAN

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

Answer Question

Click here to Login / Register your free account

Send   Reset


Related Answered Questions


Related Open Questions