I am using the following code to initialize an endpoint.
endPt = boost::asio::ip::tcp::endpoint(boost::asio::ip::address::from_string("192.168.1.21"),
boost::lexical_cast<int>(portNo));
What is the right way to initialize an endpoint if the ipaddress is in form of a char array ( say argv[1]) or a string object read from a config file. Boost docs in this link give the following.
"Construct an address from an IPv4 address."
Is the above the right way? Please help me with a code snippet.
In your code snippet, the string "192.168.1.21"
is in fact a char array such as would be obtained from argv[1]
.
endPt = boost::asio::ip::tcp::endpoint(
boost::asio::ip::address::from_string(argv[1]),
boost::lexical_cast<int>(portNo)
);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.