1
votes

I have just realized looking through TCPView that one single TCP connection established using boost::asio creates two connections. One of them using local ports and a second one with the desired remote port. Why? Is this behaviour normal? Is there a way of creating just one?

This question was originally posted several years ago:

http://boost.2283326.n4.nabble.com/ASIO-tcp-socket-async-connect-connections-count-tc3901601.html#none

but nobody replayed.

Edit:

I'm connecting to the port 8001 and this is what I see with netstat -nao:

TCP    127.0.0.1:10246        127.0.0.1:8001         ESTABLISHED     3252
TCP    127.0.0.1:10244        127.0.0.1:10245        ESTABLISHED     3252
TCP    127.0.0.1:10245        127.0.0.1:10244        ESTABLISHED     3252

Thank you!

1
Ok, I finally found a related question thanks to EJP: stackoverflow.com/questions/17945394/… - ChrisPeterson

1 Answers

0
votes

This is two connections, not three. Check the port numbers. Evidently the library creates a connection to itself for some reason.

It would be interesting to know whether it happens again when you create a second connection.