Reputation: 99
Lets say socket is a TCP welcoming socket on port 80 on some IP. It's listening. Meaning, TCP socket is created, but TCP sockets also have to have destination IP and port. When someone tries to connect and welcoming socket accepts connection, a new TCP socket is return which has a different source port number (not 80) and which is used to send data.
Am I right? Are well-known sockets "sad" because they never send actual information? How is welcoming socket TCP if it doesn't have destination IP and port?
Thanks in advance for your awesome answers
Upvotes: 1
Views: 564
Reputation: 310978
When someone tries to connect and welcoming socket accepts connection, a new TCP socket is return which has a different source port number (not 80)
No. It has the same source port: 80 in this case.
and which is used to send data.
Correct.
Am I right?
No.
Are well-known sockets "sad"
There is no such thing as a 'well-known socket', and ascribing feelings to inanimate objects is a case of the pathetic fallacy (look it up).
because they never send actual information?
A listening socket never sends information, that much is true, but the rest of it doesn't make sense.
How is welcoming socket TCP if it doesn't have destination IP and port?
Because that's the way the TCP protocol is defined, in RFC 793: a listening (passive) socket and accepted (active) sockets.
You're confusing and conflating a lot of concepts here.
Upvotes: 1
Reputation: 31193
Sockets are identified by five parts of information: client address and port, server address and port as well as protocol. If you accept a connection on a socket listening on port 80, you will get a new socket with source port still as 80, but the destination address and port are different. This way the server knows how to separate these sockets. Also the source address may be different, if the listening socket is listening on all addresses, for example.
Technically the listening socket never transmits any application layer information, but it does send information pertinent to establishing the connection.
They are also not in any way sad, they are very happy to be of assistance to their more extroverted friends and like to be on their own just directing connections around.
Upvotes: 2
Reputation: 182829
When someone tries to connect and welcoming socket accepts connection, a new TCP socket is return which has a different source port number (not 80) and which is used to send data.
This is a bit misleading. From the point of view of the server with the well-known port, the source port is still 80. The destination port is something other than 80 (typically). From the point of view of the client, the destination port is always the well known port. The port is, of course, whatever they chose.
Am I right? Are well-known sockets "sad" because they never send actual information?
No because there's no such thing as a "well-known socket". There are well-known ports, such as 80. But as I said, from the server's point of view, they're always the destination port and from the client's point of view, they're always the source port.
There is a listening socket, bound to the well-known port, and it's just used as a handle to receive incoming TCP connection. In a sense, it's "sad" because unlike most TCP sockets, it is never connected to anything.
Upvotes: 1