X-Git-Url: http://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=ccan%2Fio%2Fio.h;h=772db9293ab068e7ed425ea282d6b7e0fc07b7ce;hp=c85a5b8c5abda95afae4463574f0c648a60a6b3d;hb=b85c47bb81a9078afc5ddc51448560187348bbbf;hpb=c321a1d02755a77ae790d6e8976b2ff15edba89d;ds=sidebyside diff --git a/ccan/io/io.h b/ccan/io/io.h index c85a5b8c..772db929 100644 --- a/ccan/io/io.h +++ b/ccan/io/io.h @@ -160,6 +160,31 @@ 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. + */ +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); + /** * io_idle - plan to do nothing. *