- memset(&fds, 0, sizeof(struct pollfd));
- fds[0].fd= ptr->fd;
- fds[0].events= POLLOUT | POLLERR;
- error= poll(fds, 1, ptr->root->connect_timeout);
+ /* connect to server */
+ while (ptr->fd != -1 &&
+ connect(ptr->fd, use->ai_addr, use->ai_addrlen) < 0)
+ {
+ ptr->cached_errno= errno;
+ if (errno == EINPROGRESS || /* nonblocking mode - first return, */
+ errno == EALREADY) /* nonblocking mode - subsequent returns */
+ {
+ struct pollfd fds[1] = { [0].fd = ptr->fd, [0].events = POLLOUT };
+ int error= poll(fds, 1, ptr->root->connect_timeout);