但至今为止我所找到的答案都无济于事。
Problem: I m trying to listen to a Velodyne HDL32 that sends its packets via UDP to my pc. The OS is 32-bit Ubuntu and Boost library v1.46.
我通过Wireshark获得的数据是这样的:
Time | Source | Destination | Protocol | Length | Source Port | Destination Port
0.000000 | 192.168.17.212 | 192.168.3.255 | UDP | 1248 | https | opentable
但有了这个代码,我看不到任何数据(Port是正确的):
receiver(boost::asio::io_service& io_service,
const boost::asio::ip::address& listen_address)
: m_socket(io_service)
{
boost::asio::ip::address ipAddr = boost::asio::ip::address_v4::any();
boost::asio::ip::udp::endpoint listen_endpoint(
ipAddr, 2368);
m_socket.open(listen_endpoint.protocol());
m_socket.bind(listen_endpoint);
m_socket.async_receive_from(
boost::asio::buffer(m_data, max_length), m_sender_endpoint,
boost::bind(&receiver::handle_receive_from, this,
boost::asio::placeholders::error,
boost::asio::placeholders::bytes_transferred));
}
void handle_receive_from(const boost::system::error_code& error,
size_t bytes_recvd)
{
std::cout << "receive" << bytes_recvd << std::endl;
m_socket.async_receive_from(
boost::asio::buffer(m_data, max_length), m_sender_endpoint,
boost::bind(&receiver::handle_receive_from, this,
boost::asio::placeholders::error,
boost::asio::placeholders::bytes_transferred));
}
Can anyone identify a problem so far or do you need more information? I appreciate any help I can get.
NOTE: I m NOT running the program with root privileges!
Some thoughts: Could it be possible that boost::asio::ip::address_v4::any() won t listen to the IP ..*.255 when having subnetmask 255.255.255.0?
When using netcat, no data is shown as well. When I use Windows netcat it works quite fine. Same with Wireshark on Linux and Windows - works fine. Tried it with the as well, but with the same effect - no data.