It's part of the TCP (or UDP, etc.) header, in the packet. So the server finds out because the client tells it. This is similar to how it finds out the client's IP address (which is part of the IP header).Į.g., every TCP packet includes an IP header (with source IP, destination IP, and protocol, at least). Then there is a TCP header (with source and destination port, plus more). When the kernel receives a SYN packet (the start of a TCP connection) with a remote IP of 10.11.12.13 (in the IP header) and a remote port of 12345 (in the TCP header), it then knows the remote IP and port. If it gets an ACK back, the listen call returns a new socket, set up for that connection.Ī TCP socket is uniquely identified by the four values (remote IP, local IP, remote port, local port). You can have multiple connections/sockets, as long as at least one of those differs. ![]() ![]() Typically, the local port and local IP will be the same for all connections to a server process (e.g. All connections to sshd will be on local-ip:22).
0 Comments
Leave a Reply. |