File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Sockets and Internet Protocols and the fly likes port vs socket Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "port vs socket" Watch "port vs socket" New topic

port vs socket

iyappan sankaran
Ranch Hand

Joined: Aug 11, 2003
Posts: 58
difference between port and socket
J Kneeland
Ranch Hand

Joined: Aug 15, 2004
Posts: 31
Imagine you computer as a House with many doors. The address of your house would be equal to the the IP address of a computer. Each door would be equal to a computer's port. A socket would sit at a door and listen and talk. A socket is an a a connection to another computer. It would sit at one of your doors and yell across the street to your neighbour's house. In order to do this, you need to know what door your neighbour is listening at otherwise he can't answer. You call up your neighbour and he tells you that he is listening on port 150. You pick a random door at your house with a number above 1024 and make sure it's empty. If it isn't, you find another one and repeat.(This is usually handled by the socket and you don't need to specify this.) Then you open this door and throw a rock to your neighbour's house across the street and hit the door nunmbered 150. Your neighbour opens his door(#150) and you now can talk to him and send him data.
I agree. Here's the link:
subject: port vs socket
It's not a secret anymore!