5 #include <sys/socket.h>
7 #include <netinet/in.h>
15 class thread_exit_exception : std::exception {
22 virtual bool got_pdu(connection *c, char *b, int sz) = 0;
26 class connection : public aio_callback {
29 charbuf(): buf(NULL), sz(0), solong(0) {}
30 charbuf (char *b, int s) : buf(b), sz(s), solong(0){}
33 int solong; //amount of bytes written or read so far
36 connection(chanmgr *m1, int f1, int lossytest=0);
39 int channo() { return fd_; }
43 bool send(char *b, int sz);
51 int compare(connection *another);
64 struct timeval create_time_;
72 std::condition_variable send_complete_;
73 std::condition_variable send_wait_;
78 tcpsconn(chanmgr *m1, int port, int lossytest=0);
80 inline int port() { return port_; }
88 int tcp_; //file desciptor for accepting connection
91 std::map<int, connection *> conns_;
93 void process_accept();
97 bundle(chanmgr *m, int s, int l):mgr(m),tcp(s),lossy(l) {}
103 connection *connect_to_dst(const sockaddr_in &dst, chanmgr *mgr, int lossy=0);