7 #include <netinet/in.h>
11 constexpr size_t size_t_max = numeric_limits<size_t>::max();
13 class thread_exit_exception : exception {};
19 virtual bool got_pdu(connection *c, const string & b) = 0;
23 class connection : public aio_callback {
27 size_t solong = 0; // number of bytes written or read so far
30 connection(chanmgr *m1, int f1, int lossytest=0);
33 int channo() { return fd_; }
37 bool send(const string & b);
43 int ref() { lock rl(ref_m_); return refno_; }
45 int compare(connection *another);
59 time_point<steady_clock> create_time_;
73 tcpsconn(chanmgr *m1, in_port_t port, int lossytest=0);
75 inline in_port_t port() { return port_; }
83 socket_t tcp_; // listens for connections
86 map<int, connection *> conns_;
88 void process_accept();
92 bundle(chanmgr *m, int s, int l):mgr(m),tcp(s),lossy(l) {}
98 connection *connect_to_dst(const sockaddr_in &dst, chanmgr *mgr, int lossy=0);