diff options
Diffstat (limited to 'src/packetSource.cpp')
-rw-r--r-- | src/packetSource.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/packetSource.cpp b/src/packetSource.cpp index 5542ee9..e291175 100644 --- a/src/packetSource.cpp +++ b/src/packetSource.cpp @@ -37,6 +37,7 @@ #include "log.h" #include "resolver.h" #include "options.h" +#include "signalController.h" void PacketSource::waitUntilReady() { @@ -45,12 +46,12 @@ void PacketSource::waitUntilReady() UDPPacketSource::UDPPacketSource(std::string port) : sock_(io_service_) { - gResolver.resolveUdp("", port, boost::bind(&UDPPacketSource::onResolve, this, _1), gOpt.getResolvAddrType()); + gResolver.resolveUdp("", port, boost::bind(&UDPPacketSource::onResolve, this, _1), boost::bind(&UDPPacketSource::onError, this, _1), gOpt.getResolvAddrType()); } UDPPacketSource::UDPPacketSource(std::string localaddr, std::string port) : sock_(io_service_) { - gResolver.resolveUdp(localaddr, port, boost::bind(&UDPPacketSource::onResolve, this, _1), gOpt.getResolvAddrType()); + gResolver.resolveUdp(localaddr, port, boost::bind(&UDPPacketSource::onResolve, this, _1), boost::bind(&UDPPacketSource::onError, this, _1), gOpt.getResolvAddrType()); } void UDPPacketSource::onResolve(const boost::asio::ip::udp::endpoint& e) @@ -61,6 +62,11 @@ void UDPPacketSource::onResolve(const boost::asio::ip::udp::endpoint& e) ready_sem_.up(); } +void UDPPacketSource::onError(const std::runtime_error& e) +{ + gSignalController.inject(SIGERROR, e.what()); +} + u_int32_t UDPPacketSource::recv(u_int8_t* buf, u_int32_t len, PacketSourceEndpoint& remote) { return static_cast<u_int32_t>(sock_.receive_from(boost::asio::buffer(buf, len), remote)); |