+ *
+ * Example:
+ * struct buf {
+ * size_t len;
+ * char buf[12];
+ * };
+ *
+ * static struct io_plan show_remainder(struct io_conn *conn, struct buf *b)
+ * {
+ * printf("Only wrote: '%*s'\n", (int)b->len, b->buf);
+ * free(b);
+ * return io_close();
+ * }
+ *
+ * static void start_conn_with_part_read(int fd, void *unused)
+ * {
+ * struct buf *b = malloc(sizeof(*b));
+ *
+ * // Write message, then dump and close.
+ * b->len = sizeof(b->buf);
+ * strcpy(b->buf, "Hello world");
+ * io_new_conn(fd, io_write_partial(b->buf, &b->len, show_remainder, b));
+ * }
+ */
+#define io_write_partial(data, len, cb, arg) \
+ io_debug(io_write_partial_((data), (len), \
+ typesafe_cb_preargs(struct io_plan, void *, \
+ (cb), (arg), \
+ struct io_conn *), \
+ (arg)))
+struct io_plan io_write_partial_(const void *data, size_t *len,
+ struct io_plan (*cb)(struct io_conn *, void*),
+ void *arg);
+
+/**
+ * io_connect - plan to connect to a listening socket.
+ * @fd: file descriptor.
+ * @addr: where to connect.
+ * @cb: function to call once it's done.
+ * @arg: @cb argument
+ *
+ * This initiates a connection, and creates a plan for
+ * (asynchronously). completing it. Once complete, @len is updated
+ * and the @cb function will be called: on an error, the finish
+ * function is called instead.
+ *
+ * Note that the connect may actually be done immediately.
+ *
+ * Example:
+ * #include <sys/types.h>
+ * #include <sys/socket.h>
+ * #include <netdb.h>
+ *
+ * // Write, then close socket.
+ * static struct io_plan start_write(struct io_conn *conn, void *unused)
+ * {
+ * return io_write("hello", 5, io_close_cb, NULL);
+ * }
+ *
+ * ...
+ *
+ * int fd;
+ * struct addrinfo *addrinfo;
+ *
+ * fd = socket(AF_INET, SOCK_STREAM, 0);
+ * getaddrinfo("localhost", "8111", NULL, &addrinfo);
+ * io_new_conn(fd, io_connect(fd, addrinfo, start_write, NULL));