+/**
+ * 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));
+ */
+struct addrinfo;
+#define io_connect(fd, addr, cb, arg) \
+ io_debug(io_connect_((fd), (addr), \
+ typesafe_cb_preargs(struct io_plan, void *, \
+ (cb), (arg), \
+ struct io_conn *), \
+ (arg)))
+struct io_plan io_connect_(int fd, const struct addrinfo *addr,
+ struct io_plan (*cb)(struct io_conn *, void*),
+ void *arg);