How can you have a TCP connection back to the same port?

This may be caused by TCP simultaneous connect (mentioned on this post to LKML, see also here).

It’s possible for a program looping on trying to connect to a port within the dynamic local port range (which can be seen in /proc/sys/net/ipv4/ip_local_port_range),to succeed while the server is not listening on that port.

On a large enough number of attempts, the socket being used to connect may be bound to the same port being connected to, which succeeds due to previously mentioned simultaneous connect. You now magically have a client connected to itself

Leave a Comment