I'm using boost::asio
to capture packets on udp port. I'm just new to boost.
How can I make async_receive_from
copy data to buffer only packets with specified source ip?
相关问题
- Sorting 3 numbers without branching [closed]
- How to compile C++ code in GDB?
- Why does const allow implicit conversion of refere
- thread_local variables initialization
- What uses more memory in c++? An 2 ints or 2 funct
相关文章
- Class layout in C++: Why are members sometimes ord
- How to mock methods return object with deleted cop
- Which is the best way to multiply a large and spar
- C++ default constructor does not initialize pointe
- Selecting only the first few characters in a strin
- What exactly do pointers store? (C++)
- Converting glm::lookat matrix to quaternion and ba
- What is the correct way to declare and use a FILE
Depending on what you mean by capture packets, some code like this would work. This is modified from Boost Asio Async UDP example.
socket_
is connected to a local interface at a specifiedport
if you set port to 0 I believe it listens on all the ports.Once you receive a packet using
async_receive_from
, it will also returnsender_endpoint_
from the decoded datagram(i.e. where did the packet in question come from.) In yourhandle_receive_from
function just add a conditional statement to check for desiredsender_endpoint_
and "copy the data to buffer".Almost forgot - main function!
Hope this helps!