Options

socket and port

binarysoulbinarysoul Member Posts: 993
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

Comments

  • Options
    gojericho0gojericho0 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.
  • Options
    binarysoulbinarysoul Member Posts: 993
    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'?
    :)
  • Options
    agustinchernitskyagustinchernitsky Member Posts: 299
    If I remember correctly, socket is the combination of an IP and a port number.
  • Options
    gojericho0gojericho0 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
  • Options
    Danman32Danman32 Member Posts: 1,243
    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'?
    :)

    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.
Sign In or Register to comment.