This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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 Murach's Java Servlets and JSP this week in the Servlets 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.
It is sorta covered in the JavaRanch Style Guide.
subject: port vs socket
Similar Threads
java application to listen on port 80.
Get Application Running Process Status using java
see proxy port
Plain socket to SSL
How to find a port is free or not without catching any Exception ?