I almost don't dare to ask, but I have to.
I was playing with sockets a quite a while, but there is one thing that makes me insane. Suppose I have a server listening on port 1234 and as a client I just simply telnet to that port. Well, I the connection is established and everything is ok.
But when I use a tool to analyze all the socket connections on my system (in this case windose, yes I'm sorry), I have a listening port on 1234, which is the server part, and an established connection between server port 1234 and client port 1541 (which is random by the OS).
So with the client I can still send data to the server port 1234, which works fine. But the strange thing is, I can create a new client connecting to the server also at port 1234.
And here comes the main point. The strange thing is, on the server side it's listening on port 1234 for a new client connection, which is waiting on the accept(), but at the same time I can receive data from that same port 1234 to handle incoming data from a client.
So how is this distinguished between a client connection request on the accept() call and some regular data from an already connected client (on another thread or process) on the recv()?
I hope you understand my question, thank you.