Answer the question
In order to leave comments, you need to log in
How does one network socket handle many connections?
According to Java, they write in the literature that after the .accept () method for a client that has already passed a three-time tcp handshake, a new "network" socket is created, through which further interaction with the client takes place. ( source ) And the original server socket (which I hang up for example on port 80 for http server'a ) is used only to establish new connections.
I have doubts about this. I do not open ports for clients in the firewall, I have one open - the server one.
Question: how is it possible to handle a large number of clients through one port?
ps I realized that for each client a regular socket is created, which apparently unambiguously characterizes one client (by the connection port + client ip).
It turns out that on the server side, all requests are routed through one server socket, bound on the port? How is routing done?
Answer the question
In order to leave comments, you need to log in
It turns out that on the server side, all requests are routed through one server socket, bound on the port? How is routing done?
Each client has an outgoing port and IP. Accordingly, the OS can determine which socket to send data to when the TCP packet arrives.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question