5 #include <sys/socket.h>
7 #include <netinet/in.h>
18 virtual bool got_pdu(connection *c, char *b, int sz) = 0;
22 class connection : public aio_callback {
25 charbuf(): buf(NULL), sz(0), solong(0) {}
26 charbuf (char *b, int s) : buf(b), sz(s), solong(0){}
29 int solong; //amount of bytes written or read so far
32 connection(chanmgr *m1, int f1, int lossytest=0);
35 int channo() { return fd_; }
39 bool send(char *b, int sz);
47 int compare(connection *another);
60 struct timeval create_time_;
67 pthread_mutex_t ref_m_;
68 pthread_cond_t send_complete_;
69 pthread_cond_t send_wait_;
74 tcpsconn(chanmgr *m1, int port, int lossytest=0);
76 inline int port() { return port_; }
84 int tcp_; //file desciptor for accepting connection
87 std::map<int, connection *> conns_;
89 void process_accept();
93 bundle(chanmgr *m, int s, int l):mgr(m),tcp(s),lossy(l) {}
99 void start_accept_thread(chanmgr *mgr, int port, pthread_t *th, int *fd = NULL, int lossy=0);
100 connection *connect_to_dst(const sockaddr_in &dst, chanmgr *mgr, int lossy=0);