5 #include <sys/socket.h>
7 #include <netinet/in.h>
16 constexpr size_t size_t_max = std::numeric_limits<size_t>::max();
18 class thread_exit_exception : std::exception {
25 virtual bool got_pdu(connection *c, char *b, size_t sz) = 0;
29 class connection : public aio_callback {
32 charbuf(): buf(NULL), sz(0), solong(0) {}
33 charbuf (char *b, size_t s) : buf(b), sz(s), solong(0){}
36 size_t solong; // number of bytes written or read so far
39 connection(chanmgr *m1, int f1, int lossytest=0);
42 int channo() { return fd_; }
46 bool send(char *b, size_t sz);
54 int compare(connection *another);
67 std::chrono::time_point<std::chrono::steady_clock> create_time_;
75 std::condition_variable send_complete_;
76 std::condition_variable send_wait_;
81 tcpsconn(chanmgr *m1, unsigned int port, int lossytest=0);
83 inline unsigned int port() { return port_; }
91 int tcp_; //file desciptor for accepting connection
94 std::map<int, connection *> conns_;
96 void process_accept();
100 bundle(chanmgr *m, int s, int l):mgr(m),tcp(s),lossy(l) {}
106 connection *connect_to_dst(const sockaddr_in &dst, chanmgr *mgr, int lossy=0);