/// Less operator, needed for maps bool operator<(const port<Alloc>& rhs) const { int n = node().compare(rhs.node()); if (n > 0) return true; if (n < 0) return false; if (id() < rhs.id()) return true; if (id() > rhs.id()) return false; if (creation() < rhs.creation()) return true; if (creation() > rhs.creation()) return false; return false; }
bool print(Iterator& out, const port& p) const { using namespace printers; if (!(u16(out, p.number()) && chr<'/'>(out))) return false; switch (p.type()) { default: return chr<'?'>(out); case port::tcp: return str(out, "tcp"); case port::udp: return str(out, "udp"); case port::icmp: return str(out, "icmp"); } }
void asio_server::run(port pt) { tcp::acceptor* new_acceptor(new tcp::acceptor( io_service_, tcp::endpoint(tcp::v4(), atoi( pt.c_str() )))); acceptor_.reset(new_acceptor); async_accept( connection_handler_ ); run_listener( ); io_threads_.push_back( new boost::thread( boost::bind( &boost::asio::io_service::run, &io_service_) ) ); }
void operator()(port& p) { using port_type = std::underlying_type_t<port::port_type>; std::uniform_int_distribution<port_type> unif{0, 3}; p.number(static_cast<port::number_type>(sample())); p.type(static_cast<port::port_type>(unif(gen_))); }
bool operator== (const port<Alloc>& t) const { return id() == t.id() && node() == t.node() && creation() == t.creation(); }