/* This file is part of the YAZ toolkit.
- * Copyright (C) 1995-2013 Index Data
+ * Copyright (C) Index Data
* See the file LICENSE for details.
*/
/**
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;
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;
}
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)))