X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=src%2Ftcpip.c;h=5ed4c9b6f16bd4e9d04b8a7fa3c7b4f6cf52a973;hp=6bb8a9071d02686936aa12c100a6ad96643ca255;hb=b06636208651777c08e2456bf3b5953fc3c0f2c2;hpb=2658161722cc73f144d0f3d5695b13d00ffef1e7 diff --git a/src/tcpip.c b/src/tcpip.c index 6bb8a90..5ed4c9b 100644 --- a/src/tcpip.c +++ b/src/tcpip.c @@ -227,17 +227,13 @@ COMSTACK tcpip_type(int s, int flags, int protocol, void *vp) sp->altbuf = 0; sp->altsize = sp->altlen = 0; sp->towrite = sp->written = -1; - if (protocol == PROTO_WAIS) - sp->complete = completeWAIS; - else - sp->complete = cs_complete_auto; + sp->complete = cs_complete_auto; sp->connect_request_buf = 0; sp->connect_request_len = 0; sp->connect_response_buf = 0; sp->connect_response_len = 0; - p->timeout = COMSTACK_DEFAULT_TIMEOUT; TRC(fprintf(stderr, "Created new TCPIP comstack h=%p\n", p)); return p; @@ -367,7 +363,7 @@ struct addrinfo *tcpip_getaddrinfo(const char *str, const char *port, if (!strcmp("@", host)) { hints.ai_flags = AI_PASSIVE; - hints.ai_family = AF_INET6; + hints.ai_family = AF_UNSPEC; error = getaddrinfo(0, port, &hints, &res); *ipv6_only = 0; } @@ -463,15 +459,27 @@ void *tcpip_straddr(COMSTACK h, const char *str) int s = -1; for (ai = sp->ai; ai; ai = ai->ai_next) { - s = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol); - if (s != -1) - break; + if (ai->ai_family == AF_INET6) + { + s = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol); + if (s != -1) + break; + } + } + if (s == -1) + { + for (ai = sp->ai; ai; ai = ai->ai_next) + { + s = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol); + if (s != -1) + break; + } } if (s == -1) return 0; assert(ai); h->iofile = s; - if (ipv6_only >= 0 && + if (ai->ai_family == AF_INET6 && ipv6_only >= 0 && setsockopt(h->iofile, IPPROTO_IPV6, IPV6_V6ONLY, &ipv6_only, sizeof(ipv6_only)))