I have been bothered for a long while by some confusions among
- internet domain socket provided by Linux,
- transport protocols (TCP/UDP)'s socket and
- transport protocols (TCP/UDP)'s port.
Replies on some related posts on SO have lots of ambiguities and inconsistencies and make my confusions even more.
Both Linux and transport protocols (TCP/UDP) have concepts "socket". How do the two concepts differ? Is internet domain socket (represented as a file?) provided by Linux a (faithful) implementation of socket in transport protocols (TCP/UDP)? (I guess yes, and if that is true, we can interchangeably use the two terms.)
Conceptually, is it correct to think of a port in a transport protocol (TCP/UDP) as a tuple (IP address, transport protocol, port number) or just port number? (I guess a port is a tuple (IP address, transport protocol, port number), because I have been educated several times that the same port number with a different IP address or a different transport protocol represents a different port. In that sense, port and socket (in transport protocols) seem to be an identical concept.) It seems the established name "port" means "port number" only, and I will explicitly use "port number" in the following to avoid unnecessary confusions.
What are the relations between socket (in transport protocols) and tuple (IP address, transport protocol, port number)? Is there a bijective mapping between the set of sockets and the set of tuples (IP address, transport protocol, port number)? Must there be one or more sockets for each tuple (IP address, transport protocol, port number), and must there be one or more tuples (IP address, transport protocol, port number) for each socket? Can two sockets share the same tuple (IP address, transport protocol, port number)? Can two tuples (IP address, transport protocol, port number) share the same socket?
I heard that two processes can share the same socket (which I understand it in the way that two processes can share a file, assuming Linux's internet domain socket and transport protocols (TCP/UDP)'s socket can be used interchangeably). Can two processes share the same tuple (IP address, transport protocol, port number)?
I heard that two connections can't share the same socket (assuming Linux's internet domain socket and transport protocols (TCP/UDP)'s socket can be used interchangeably). Can two connections share the same tuple (IP address, transport protocol, port number)?
Thanks.
</dev/tcp/towel.blinkenlights.nl/23
. (Not a real file, just some bash syntax, but you can have file-systems that do this).