+static int cont_connect(COMSTACK h)
+{
+#if HAVE_GETADDRINFO
+ tcpip_state *sp = (tcpip_state *)h->cprivate;
+ struct addrinfo *ai = sp->ai_connect;
+ while (ai && (ai = ai->ai_next))
+ {
+ int s;
+ s = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
+ if (s != -1)
+ {
+#if HAVE_GNUTLS_H
+ if (h->type == ssl_type && sp->session)
+ {
+ gnutls_bye(sp->session, GNUTLS_SHUT_WR);
+ gnutls_deinit(sp->session);
+ sp->session = 0;
+ }
+#endif
+#ifdef WIN32
+ closesocket(h->iofile);
+#else
+ close(h->iofile);
+#endif
+ TRC(fprintf(stderr, "Other socket call fd=%d\n", s));
+ h->state = CS_ST_UNBND;
+ h->iofile = s;
+ tcpip_set_blocking(h, h->flags);
+ return tcpip_connect(h, ai);
+ }
+#endif
+ }
+ h->cerrno = CSYSERR;
+ return -1;
+}
+
+