What is the difference between a port and a socket?

后端 未结 30 2091
旧巷少年郎
旧巷少年郎 2020-11-22 14:31

This was a question raised by one of the software engineers in my organisation. I\'m interested in the broadest definition.

30条回答
  •  感动是毒
    2020-11-22 15:12

    With some analogy

    Although a lot technical stuff is already given above for sockets... I would like to add my answer, just in case , if somebody still could not feel the difference between ip, port and sockets

    Consider a server S,

    and say person X,Y,Z need a service (say chat service) from that server S

    then

    IP address tells --> who? is that chat server 'S' that X,Y,Z want to contact

    okay, you got "who is the server"

    but suppose that server 'S' is providing some other services to other people as well,say 'S' provides storage services to person A,B,C

    then

    port tells ---> which? service you (X,Y,Z) need i.e. chat service and not that storage service

    okay.., you make server to come to know that 'chat service' is what you want and not the storage

    but

    you are three and the server might want to identify all the three differently

    there comes the socket

    now socket tells--> which one? particular connection

    that is , say ,

    socket 1 for person X

    socket 2 for person Y

    and socket 3 for person Z

    I hope it helps someone who was still confused :)

提交回复
热议问题