LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   what is the difference between socket & port? (https://www.linuxquestions.org/questions/linux-newbie-8/what-is-the-difference-between-socket-and-port-323674/)

fssengg 05-15-2005 07:28 AM

what is the difference between socket & port?
 
hai
Can anybody tell me what is the fundamental difference between a socket and a port?
How they r represented actually?

Vookimedlo 05-15-2005 08:52 AM

Port represents service, which computer offers in the network.

Socket is communication resource.

raviksp 05-15-2005 10:47 PM

Port is application running on that socket.So port uses Socket to deliver the pkt to correct application.
Socket is communication resource.POrt is just to identify the one among many applications running on that socket..

Maelstrom65 05-15-2005 11:07 PM

The way I understand it is...
 
A port is (as was mentioned already) a service or resource. The way into and out of an application. When you call up a web page, you're calling to port 80 on the target machine from some port between 1024 and 65,535 on your machine (called Ephemeral Ports)... When those two ports establish communication (you download your webpage) a "Socket" is created. Kinda like a circuit I guess.

Hope that makes sense...

Cheers

Dark_Helmet 05-16-2005 12:05 AM

Ok, since everybody else is doing it... :)

A port is a service provided by a machine. That service is identified by a number. There are a lot of standardized port numbers for popular services. Port 22 is for FTP. Port 80 is for HTTP. There are many, many others.

A socket is the way a server and a client keep track of requests. For example, LQ.org allows access to port 80 (HTTP) for the purposes of reading these forums. When my computer requests to see the content of the forums, a socket is created, and a "conversation" between the server and my machine occurs. The thing is, I'm not the only person trying to read the forums. So, to keep the server from getting conversations mixed up, each request gets a different socket. As I recall, there can be 64K sockets (or simultaneous conversations if you prefer). The thing to note is this: that's 64K sockets per port, because all these requests are coming into the server on port 80, right?

So, ports are a broad reference to a type of service, whereas a socket refers to a specific connection on a specific port.

EDIT:
Oh, forgot... ports and sockets are both typically represented as integers. At I fairly certain; both can take a value from 0 to ( 64K - 1 )


All times are GMT -5. The time now is 08:35 AM.