-#define io_wake(conn, next, arg) \
- io_wake_((conn), \
- typesafe_cb_preargs(struct io_op *, void *, \
- (next), (arg), struct io_conn *), \
+struct addrinfo;
+#define io_connect(conn, addr, next, arg) \
+ io_connect_((conn), (addr), \
+ typesafe_cb_preargs(struct io_plan *, void *, \
+ (next), (arg), \
+ struct io_conn *), \
+ (arg))
+
+struct io_plan *io_connect_(struct io_conn *conn, const struct addrinfo *addr,
+ struct io_plan *(*next)(struct io_conn *, void *),
+ void *arg);
+
+/**
+ * io_wait - leave a plan idle until something wakes us.
+ * @conn: the connection that plan is for.
+ * @waitaddr: the address to wait on.
+ * @dir: IO_IN or IO_OUT
+ * @next: function to call after waiting.
+ * @arg: @next argument
+ *
+ * This leaves the input or output idle: io_wake(@waitaddr) will be
+ * called later to restart the connection.
+ *
+ * Example:
+ * // Silly example to wait then close.
+ * static struct io_plan *wait(struct io_conn *conn, void *b)
+ * {
+ * return io_wait(conn, b, IO_IN, io_close_cb, NULL);
+ * }
+ */
+#define io_wait(conn, waitaddr, dir, next, arg) \
+ io_wait_((conn), (waitaddr), (dir), \
+ typesafe_cb_preargs(struct io_plan *, void *, \
+ (next), (arg), \
+ struct io_conn *), \