4
votes

I want to connect to a server socket specified by a destination ip address and port number.

boost::asio::connect seems it does not allow to use this. I have ip destination as a unsigned int value.

Update: I am able to do

ba::ip::tcp::endpoint endpoint( ba::ip::address(ba::ip::address_v4(req.IpDst())), ntohs(req.Port()));

But how can I use endpoint with connect ?

1
Have a look at the constructor for basic_endpoint boost.org/doc/libs/1_47_0/doc/html/boost_asio/reference/…mark
@mark thanks for pointing that out I've just discovered that myself. But how can I use endpoint with connect ? Only saw it in use with resolver iterator...Ghita

1 Answers

6
votes

It is possible to use:

socket.connect(endpoint);