X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Ftcpip.c;h=a16fe5eb202c58d9edaf00a45c5f67a4ec29fb1d;hb=9dfcbb70828f8d5b524c9bb45852246ae1dd6878;hp=6c674d4aa6e074bfe57f6a189fb1c95717489f08;hpb=e61e837408b141d4a56eaea0abea76ceebd19b7e;p=yaz-moved-to-github.git diff --git a/src/tcpip.c b/src/tcpip.c index 6c674d4..a16fe5e 100644 --- a/src/tcpip.c +++ b/src/tcpip.c @@ -2,7 +2,7 @@ * Copyright (C) 1995-2006, Index Data ApS * See the file LICENSE for details. * - * $Id: tcpip.c,v 1.29 2006-09-06 16:03:52 adam Exp $ + * $Id: tcpip.c,v 1.31 2006-09-21 15:55:25 adam Exp $ */ /** * \file tcpip.c @@ -322,10 +322,15 @@ void *tcpip_straddr(COMSTACK h, const char *str) sp->ai = tcpip_getaddrinfo(str, port); if (sp->ai && h->state == CS_ST_UNBND) { - int s; + int s = -1; struct addrinfo *ai = sp->ai; - s = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol); - if (s < 0) + for (; 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; h->iofile = s; @@ -560,7 +565,7 @@ static int tcpip_bind(COMSTACK h, void *address, int mode) #ifdef WIN32 BOOL one = 1; #else - unsigned long one = 1; + int one = 1; #endif #if HAVE_GETADDRINFO