socket and port
binarysoul
Member Posts: 993
in CCNA & CCENT
With respect to CCNA alone, what is the difference between a port and a socket. I'm readking Odom's CCNA intro book, i am confused.
I thought they were the same, can you please clarify
I thought they were the same, can you please clarify
Comments
-
gojericho0 Member Posts: 1,059 ■■■□□□□□□□Think of a computer as a house and a port as a window into the house. The more ports you have the more windows and possible openings you have to get inside the house. For example port 23 is used for telnet service. If we know a computer has port 23 open, how do we establish a connection to it? That is where sockets come in. A socket is used to form a session using the combination of ip address and port. So if we say something like telnet 192.168.1.100 we are saying connect to computer 192.168.1.100 on port 23.
-
binarysoul Member Posts: 993gojericho0, thanks, so from a client-server point of view is it correct to say that 'port' is used by server while 'socket' is used by client. For example, if the server has port 80 open and the client connects to it using a random port above 1024, e.g. 1030, then 1030 is a socket.
In other words, is it correct to say a client opens a connection to a 'port' on a server using a 'socket'?
-
agustinchernitsky Member Posts: 299If I remember correctly, socket is the combination of an IP and a port number.
-
gojericho0 Member Posts: 1,059 ■■■□□□□□□□binarysoul wrote:gojericho0, thanks, so from a client-server point of view is it correct to say that 'port' is used by server while 'socket' is used by client. For example, if the server has port 80 open and the client connects to it using a random port above 1024, e.g. 1030, then 1030 is a socket.
In other words, is it correct to say a client opens a connection to a 'port' on a server using a 'socket'?
Ports and sockets are used by both the client and server. In your example above the server would be accepting incoming connections on PORT 80 and the client would be recieving and responding on PORT 130. When you first want to connect to a webserver you are using the address and the port saying I want to connect to this address using this port: 7.7.7.7:80 the webserver would see the source ip and source port and respond to the request sending info at 192.168.1.100:130 -
Danman32 Member Posts: 1,243binarysoul wrote:gojericho0, thanks, so from a client-server point of view is it correct to say that 'port' is used by server while 'socket' is used by client. For example, if the server has port 80 open and the client connects to it using a random port above 1024, e.g. 1030, then 1030 is a socket.
In other words, is it correct to say a client opens a connection to a 'port' on a server using a 'socket'?
I used to consider port and socket synonymous, but after what everyone chimed in, I have to agree: socket is a combination of IP and port. A port is part of a socket. So is an IP.
And saying this makes IIS virtual websites more explainable. Each site has to have a unique socket, or socket and host header. -
forbesl Member Posts: 454