id summary reporter owner description type status milestone component version severity resolution keywords cc 9406 [asio] The asio handle shouldnot be called icerlion@… chris_kohlhoff "I want to write a UDP server, which can send and receive package. The following is the demo code: // Begin of code #include ""stdafx.h"" #include ""boost/bind.hpp"" #include ""boost/asio.hpp"" class UDPServer { public: UDPServer() :m_socket(m_io_service), m_timer(m_io_service) { } virtual ~UDPServer() { } void Initialize(const std::string& strIP, int nPort) { boost::system::error_code ec; boost::asio::ip::address ad = boost::asio::ip::address::from_string(strIP, ec); boost::asio::ip::udp::endpoint ep(ad, nPort); m_socket.open(ep.protocol()); m_socket.bind(ep, ec); { // TEST CODE: boost::asio::ip::udp::endpoint ep(boost::asio::ip::address::from_string(""172.18.8.111"", ec), 8001); m_vServerGroup.push_back(ep); } } void Start() { StartAsyncReceiveFrom(); NoticeSelfUp(); while (true) { boost::system::error_code ec; m_io_service.poll(ec); } } void SendUDPMsg(const char* pMsg, int nLen, boost::asio::ip::udp::endpoint& dest_ep) { m_socket.async_send_to( boost::asio::buffer(pMsg, nLen), dest_ep, boost::bind(&UDPServer::HandleSendTo, this, _1, _2, boost::ref(dest_ep))); } protected: void NoticeSelfUp() { size_t count = m_vServerGroup.size(); char* pBuff = ""this is up""; for (size_t i = 0; i < count; ++i) { SendUDPMsg(pBuff, strlen(pBuff), m_vServerGroup[i]); } m_timer.expires_from_now(boost::posix_time::seconds(5)); m_timer.async_wait(boost::bind(&UDPServer::NoticeSelfUp, this)); } void HandleReceiveFrom(const boost::system::error_code& ec, size_t bytes_recvd) { if (ec) { std::cout<<""HandleReceiveFrom error: \t""< m_vServerGroup; enum { max_length = 1024 }; char m_buff[max_length]; }; int _tmain(int argc, _TCHAR* argv[]) { UDPServer server; server.Initialize(""172.18.8.111"", 8000); server.Start(); return 0; } // End of code What's more, localmachine IP is 172.18.8.111, the port number 8001 is not opened. After I call SendUDPMsg, the handle UDPServer::HandleReceiveFrom is called, but there is no receive operation for the socket, I just called the send function. In my opinion, the HandleReceiveFrom should not be called!" Bugs closed To Be Determined asio Boost 1.55.0 Problem invalid