boost::asio::tcp -> asyncconnect generates multiple sockets

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

boost::asio::tcp -> asyncconnect generates multiple sockets

Hert
hello,


I noticed that when asynchronously connecting to an acceptor on localhost using  boost::asio::ip::tcp::socket generates 2 TCP sockets on the system. One to the acceptor and one to the other one. Stepping into the code I can see where it is done, but I don't understand why. So why is this extra TCP socket there?

thanks in advance,
Gert
Reply | Threaded
Open this post in threaded view
|

Re: boost::asio::tcp -> asyncconnect generates multiple sockets

Michael Lindner
A TCP connection has two ends. Since you are connecting to localhost, both the client side and server side socket are on the same machine. If you were connecting to a remote host one socket would have been created on the client machine and the other on the server machine.


HTH,
Mike

On Wed, Jul 6, 2011 at 2:58 AM, Hert <[hidden email]> wrote:
hello,


I noticed that when asynchronously connecting to an acceptor on localhost
using  boost::asio::ip::tcp::socket generates 2 TCP sockets on the system.
One to the acceptor and one to the other one. Stepping into the code I can
see where it is done, but I don't understand why. So why is this extra TCP
socket there?

thanks in advance,
Gert

--
View this message in context: http://boost.2283326.n4.nabble.com/boost-asio-tcp-asyncconnect-generates-multiple-sockets-tp3647856p3647856.html
Sent from the Boost - Users mailing list archive at Nabble.com.
_______________________________________________
Boost-users mailing list
[hidden email]
http://lists.boost.org/mailman/listinfo.cgi/boost-users


_______________________________________________
Boost-users mailing list
[hidden email]
http://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: boost::asio::tcp -> asyncconnect generates multiple sockets

Hert
Yes I understand that. This is not the issue. I am not considering the socket generated by the acceptor (sorry for the confusion). The client side seems to generate 2 sockets!

From tcpview (sysinternals):
Test.exe:3440 TCP PC-ENG1-13:3144 localhost:3145 ESTABLISHED
Test.exe:3440 TCP PC-ENG1-13:3145 localhost:3144 ESTABLISHED
Test.exe:3440 TCP PC-ENG1-13:3146 localhost:50000 ESTABLISHED


The last one is the socket between the client and the server.
The first two connect to each other, but why are these generated?? We see this happening after internally in the boost library the "reactor" is started.
The demo program "chatserver" and "chatclient" have the same behaviour.