21 #include <boost/algorithm/string/trim.hpp> 29 : replies_ (true), emptyReplies_ (true), target_ (),
31 readevent_ (
"senf::console::UDPServer::readevent",
34 senf::scheduler::FdEvent::EV_READ),
35 parser_ (), executor_ ()
39 SENF_LOG((
"UDP Console server started at " << address ));
44 readevent_ (
"senf::console::UDPServer::readevent",
47 senf::scheduler::FdEvent::EV_READ),
48 parser_ (), executor_ ()
52 SENF_LOG((
"UDP Console server started at " << address ));
65 "Internal failure: INet6 address on INet4 socket ??" );
74 "Internal failure: INet4 address on INet6 socket ??" );
81 emptyReplies_ = enable;
97 prefix_ void senf::console::UDPServer::handleInput(
int events)
108 handle_.
readfrom(data, address, 0u);
112 std::stringstream stream;
114 parser_.
parse(data, boost::bind<void>( boost::ref(executor_), boost::ref(stream), _1));
120 stream << ex.
message() <<
'\n';
124 catch (std::exception & ex) {
125 stream << ex.what() <<
'\n';
128 if (replies_ && (emptyReplies_ || ! stream.str().empty())) {
131 if (stream.str().empty())
133 handle_.
writeto(address, stream.str());
static short const addressFamily
void mcAddMembership(INet6Address const &mcAddr) const
UDPServer & replies(bool enable)
Enable or disable reply packets.
void mcAddMembership(INet4Address const &mcAddr) const
Config/console tree directory node.
u8 data[SPECTRAL_HT20_NUM_BINS]
std::string backtrace() const
void parse(std::string const &command, Callback cb)
Parse string.
boost::function< R(Args)> membind(R(T::*fn)(Args), T *ob)
UDPServer(senf::INet4SocketAddress const &address)
Open UDP server on address.
ProtocolClientSocketHandle< UDPv6SocketProtocol > UDPv6ClientSocketHandle
DirectoryNode & root() const
Get root node.
boost::range_const_iterator< ForwardReadableRange const >::type writeto(AddressParam addr, ForwardReadableRange const &range)
Thrown by built-in 'exit' command.
DirectoryNode & cwd() const
Current working directory.
#define SENF_ASSERT(x, comment)
static short const addressFamily
UDPServer & emptyReplies(bool enable)
Enable or disable empty reply packets.
std::string message() const
INet6Address address() const
DirectoryNode & chroot() const
Get root node.
std::pair< std::string, Address > readfrom(unsigned limit=0)
INet4Address address() const
ProtocolClientSocketHandle< UDPv4SocketProtocol > UDPv4ClientSocketHandle