GeekInterview.com
Series: Subject: Topic:
Question: 132 of 1115

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

Asked by: questioninterest | Member Since Oct-2005 | Asked on: Nov 9th, 2006

View all questions by questioninterest

Showing Answers 1 - 5 of 5 Answers
tarunarora

Answered On : Nov 14th, 2006

View all answers by tarunarora

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

  
Login to rate this answer.
Rajasekar

Answered On : 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

  
Login to rate this answer.
Thirunavukkarasu. C

Answered On : Jan 19th, 2007

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

Socket:

            Its completely based on the client side..

Server-Socket:

           Its completely based on server side..

  
Login to rate this answer.
dinesh_greekinterview

Answered On : 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(172.0.0.1,8000);
                                                  

  
Login to rate this answer.
kritika jha

Answered On : Jun 13th, 2009

View all answers by kritika jha

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,
whereas
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 "127.0.0.1" and might be
your subnet address in case of some LAN

Yes  1 User has rated as useful.
  
Login to rate this answer.

Give your answer:

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

Related Open Questions

Ads

Connect

twitter fb Linkedin GPlus RSS

Ads

Interview Question

 Ask Interview Question?

 

Latest Questions

Interview & Career Tips

Get invaluable Interview and Career Tips delivered directly to your inbox. Get your news alert set up today, Once you confirm your Email subscription, you will be able to download Job Inteview Questions Ebook . Please contact me if you there is any issue with the download.