#include <sys/wait.h>
#include <stdio.h>
-#ifndef PORT
#define PORT "65016"
-#endif
struct data {
struct io_listener *l;
static struct io_plan *io_done(struct io_conn *conn, struct data *d)
{
d->state++;
- if (d->state == 3)
- return io_close(conn);
- return io_wait(conn, d, io_close_cb, NULL);
+ return io_halfclose(conn);
}
static struct io_plan *init_conn(struct io_conn *conn, struct data *d)
io_close_listener(d->l);
- return io_duplex(io_read(conn, d->buf, sizeof(d->buf), io_done, d),
+ return io_duplex(conn,
+ io_read(conn, d->buf, sizeof(d->buf), io_done, d),
io_write(conn, d->wbuf, sizeof(d->wbuf), io_done, d));
}