- /* --- Finally, set up the destination and try the connect --- */
-
- {
- struct sockaddr_in sin;
-
- memset(&sin, 0, sizeof(sin));
- sin.sin_family = AF_INET;
- sin.sin_addr.s_addr = daddr;
- sin.sin_port = dport;
- if (connect(fd, (struct sockaddr *)&sin, sizeof(sin)) < 0) {
- if (errno != EINPROGRESS)
- goto fail_close;
- c->func = func;
- c->p = p;
- sel_initfile(s, &c->writer, fd, SEL_WRITE, conn_connect, c);
- sel_addfile(&c->writer);
- } else
- func(fd, p);
- }
+/* --- @conn_init@ --- *
+ *
+ * Arguments: @conn *c@ = pointer to connection block
+ * @sel_state *s@ = pointer to select state to attach to
+ * @int fd@ = file descriptor of socket to connect
+ * @struct sockaddr *dst@ = destination address
+ * @int dsz@ = size of destination address
+ * @void (*func)(int fd, void *p) = handler function
+ * @void *p@ = argument for the handler function
+ *
+ * Returns: Zero on success, nonzero on failure.
+ *
+ * Use: Sets up a nonblocking connect job. The socket should already
+ * be bound if you care about that sort of thing. When the
+ * connection completes, the handler function is called with the
+ * connected socket as an argument. If the connect fails rather
+ * than completes, the socket is closed, and the handler is
+ * informed of this by being passed a negative file descriptor.
+ * In either case, the select job is then removed.
+ */