UDP: socket::open does not take an endpoint
Hello, boost::asio::ip::udp::socket offers two ways to open: a) pass io_service and endpoint to the socket::socket b) pass io_service to socket::socket, then call socket::open === The UDP async server example uses method (a): boost::asio::ip::udp::socket Socket( IoService, boost::asio::ip::udp::endpoint(boost::asio::ip::udp::v4(), 13)); === Question 1: Why doesn't boost UDP allow me to use method (b) with an endpoint? For example, this is impossible: boost::asio::ip::udp::socket Socket(IoService); Socket.open(boost::asio::ip::udp::endpoint(boost::asio::ip::udp::v4(), 13)); // error: open does not take a boost::asio::ip::udp::endpoint === Question 2: How can I modify the UDP async server example to use method (b)? Thank you, Chris
2013/5/9 Chris Stankevitz
Question 1:
Why doesn't boost UDP allow me to use method (b) with an endpoint? For example, this is impossible:
boost::asio::ip::udp::socket Socket(IoService);
Socket.open(boost::asio::ip::udp::endpoint(boost::asio::ip::udp::v4(), 13));
// error: open does not take a boost::asio::ip::udp::endpoint
Hi, You need to use connect() member function. http://www.boost.org/doc/libs/1_53_0/doc/html/boost_asio/reference/basic_dat... -- Regards, niXman ___________________________________________________ Dual-target(32 & 64-bit) MinGW compilers for 32 and 64-bit Windows: http://sourceforge.net/projects/mingwbuilds/ ___________________________________________________ Another online IDE: http://liveworkspace.org/
2013/5/9 niXman
You need to use connect() member function. http://www.boost.org/doc/libs/1_53_0/doc/html/boost_asio/reference/basic_dat...
Or bind(), if I understood you correctly. -- Regards, niXman ___________________________________________________ Dual-target(32 & 64-bit) MinGW compilers for 32 and 64-bit Windows: http://sourceforge.net/projects/mingwbuilds/ ___________________________________________________ Another online IDE: http://liveworkspace.org/
On Wed, May 8, 2013 at 1:38 PM, niXman
Or bind(), if I understood you correctly.
niXman, Thank you. Yes, it appears my invocation of the constructor just calls open followed by bind. I could have figured this out myself had I read the constructor's online documentation or had I just stepped into the constructor to see what it was doing.... both of which I did after reading your response. Thanks again, Chris
participants (2)
-
Chris Stankevitz
-
niXman