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, char *b, size_t sz) = 0;
23 class connection : public aio_callback {
26 charbuf(): buf(NULL), sz(0), solong(0) {}
27 charbuf (char *b, size_t s) : buf(b), sz(s), solong(0){}
30 size_t solong; // number of bytes written or read so far
33 connection(chanmgr *m1, int f1, int lossytest=0);
36 int channo() { return fd_; }
40 bool send(char *b, size_t sz);
48 int compare(connection *another);
61 time_point<steady_clock> create_time_;
75 tcpsconn(chanmgr *m1, unsigned int port, int lossytest=0);
77 inline unsigned int port() { return port_; }
85 int tcp_; //file desciptor for accepting connection
88 map<int, connection *> conns_;
90 void process_accept();
94 bundle(chanmgr *m, int s, int l):mgr(m),tcp(s),lossy(l) {}
100 connection *connect_to_dst(const sockaddr_in &dst, chanmgr *mgr, int lossy=0);