virtual ~connection_delegate() {}
};
-class connection : public aio_callback, public enable_shared_from_this<connection> {
+class connection : private aio_callback, public enable_shared_from_this<connection> {
public:
struct charbuf {
string buf;
void closeconn();
bool send(const string & b);
- void write_cb(int s);
- void read_cb(int s);
time_point<steady_clock> create_time() const { return create_time_; }
static shared_ptr<connection> to_dst(const sockaddr_in &dst, connection_delegate *mgr, int lossy=0);
private:
+ void write_cb(int s);
+ void read_cb(int s);
bool readpdu();
bool writepdu();
cond send_wait_;
};
-class tcpsconn {
+class tcpsconn : private aio_callback {
public:
tcpsconn(connection_delegate *m1, in_port_t port, int lossytest=0);
~tcpsconn();
inline in_port_t port() { return port_; }
- void accept_conn();
private:
+ void write_cb(int) {}
+ void read_cb(int s);
+
in_port_t port_;
mutex m_;
- thread th_;
- file_t pipe_[2];
socket_t tcp_; // listens for connections
connection_delegate *mgr_;
int lossy_;
map<int, shared_ptr<connection>> conns_;
-
- void process_accept();
};
#endif