7 #include <netinet/in.h>
10 constexpr size_t size_t_max = numeric_limits<size_t>::max();
12 class thread_exit_exception : exception {};
18 virtual bool got_pdu(connection *c, const string & b) = 0;
22 class connection : public aio_callback {
26 size_t solong = 0; // number of bytes written or read so far
29 connection(chanmgr *m1, int f1, int lossytest=0);
32 int channo() { return fd_; }
36 bool send(const string & b);
42 int ref() { lock rl(ref_m_); return refno_; }
44 int compare(connection *another);
58 time_point<steady_clock> create_time_;
72 tcpsconn(chanmgr *m1, in_port_t port, int lossytest=0);
74 inline in_port_t port() { return port_; }
82 int tcp_; //file desciptor for accepting connection
85 map<int, connection *> conns_;
87 void process_accept();
91 bundle(chanmgr *m, int s, int l):mgr(m),tcp(s),lossy(l) {}
97 connection *connect_to_dst(const sockaddr_in &dst, chanmgr *mgr, int lossy=0);