2 step1(conn): read(conn), then step2
3 step2(conn): write(conn), then close
6 step1(conn): read(conn), then step2
7 step2(conn): write(otherconn), then step1
9 Pass-through-and-connect:
10 step1(conn): read(conn), then step2
11 step2(conn): connect(otherconn), then step3
12 step3(conn): write(otherconn), then step1
15 step1(conn): read(conn), then step2
16 step2(conn): for c in allcons: write(c). goto step1
20 void event(struct io_event *done)
22 char *buf = done->priv;
25 e = queue_read(done, done->conn, buf, 100);
26 e = queue_write(e, done->conn, buf, 100);
27 queue_close(e, done->conn);
33 struct conn *rconn, *wconn;
36 void event(struct io_event *done)
38 struct passthru *p = done->priv;
41 e = queue_read(done, p->rconn, p->buf, 100);
42 e = queue_write(e, p->wconn, buf, 100);
43 queue_event(e, event);
47 struct list_head clients;
55 struct list_node list;
56 struct connection *conn;
57 struct buffer *rbuf, *wbuf;
60 void broadcast(struct io_event *done)
62 struct client *i, *c = done->conn->priv;
65 list_for_each(&clients, i, list) {
66 e = queue_write(done, i->conn, c->buf->buf, 100);
69 queue_event(e, drop_ref);
74 void event(struct io_event *done)
76 struct client *c = done->conn->priv;
79 assert(c->conn == done->conn);
80 c->buf = malloc(sizeof(*c->buf));
82 e = queue_read(done, c->conn, c->buf->buf, 100);
83 e = queue_event(e, broadcast);
87 step1(conn): read(conn), then step2
88 step2(conn): for c in allcons: write(c). goto step1