On 24/09/2019 17:43, JH wrote:
Did you refer to use boost::asio::ip::tcp::endpoint(boost::asio::ip::address::from_string(wifi_ip_address), portNumber)?
Yes. With socket.bind().
I think you were talking about server side of default 0.0.0.0, it was my fault not being clear. Anyway, can it be done to bind client side interface IP address such as WiFi IP address? Is it possible to specify local IP address in boost::asio::ip::tcp::resolver::query query(remoteServerIpAddress, portNumber) ?
No, you need to call bind in the client prior to using the socket for anything. Normally you don't call bind on the client side because you want the default of any address and any port, but if you want a specific address (or specific port) then you have to call it. (This is why you always see it called on the server side too, since you want a specific port there.) You can pass 0 for the port number if you want it to be automatically chosen as usual; it's rare (and generally not recommended, although needed in a few cases) for the client to request a specific port number.