Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Doubt in ServerSocket and Socket

 
Abhijit Das
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

what is the difference between the the Socket object created by client side as



and the Socket object created in the Server side as


Next, should I use the sockets reversely ?
 
Rob Spoor
Sheriff
Pie
Posts: 20608
63
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A socket has two end points - one on the client and one on the server, even if the client and server are on the same physical machine.

The first call creates the end point on the client side. ServerSocket.accept returns the end point on the server side. They are two different objects, but linked through the network.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic