From a89fa4618d750ca17ffabe6dd6bb331a9eae3e51 Mon Sep 17 00:00:00 2001 From: imaginos Date: Mon, 31 Mar 2008 06:15:28 +0000 Subject: [PATCH] removing connect() completely. replacing with hint to AI_ADDRCONFIG git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@998 726aef4b-f618-498e-8847-2d620e286838 --- Csocket.cpp | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-) diff --git a/Csocket.cpp b/Csocket.cpp index 31e6f606..53144471 100644 --- a/Csocket.cpp +++ b/Csocket.cpp @@ -187,6 +187,11 @@ int GetAddrInfo( const CS_STRING & sHostname, Csock *pSock, CSSockAddr & csSockA hints.ai_socktype = SOCK_STREAM; hints.ai_protocol = IPPROTO_TCP; +#ifdef AI_ADDRCONFIG + hints.ai_flags = AI_ADDRCONFIG; +#endif /* AI_ADDRCONFIG */ + + int iRet = getaddrinfo( sHostname.c_str(), NULL, &hints, &res ); if( iRet == EAI_AGAIN ) return( EAGAIN ); @@ -207,26 +212,6 @@ int GetAddrInfo( const CS_STRING & sHostname, Csock *pSock, CSSockAddr & csSockA if( ( csSockAddr.GetAFRequire() != CSSockAddr::RAF_ANY ) && ( pRes->ai_family != csSockAddr.GetAFRequire() ) ) continue; // they requested a special type, so be certain we woop past anything unwanted -/** - * I still don't like this approach, so commenting for now. the caveat is that for ipv6 to work properly on a host - * that resolves to both ipv4 & ipv6, you need to bind to an ip first. - * - if( csSockAddr.GetAFRequire() == CSSockAddr::RAF_ANY ) - { - // this is a quick check to see if we can connect to this type of outside port (ipv6 or ipv4) - // this doesn't do an actual connection (man connect), but its a great way to validate a possible connection canidate - bool bContinue = false; - int iTestFD = socket( pRes->ai_family, SOCK_DGRAM, pRes->ai_protocol ); - if( iTestFD >= 0 ) - { - if( connect( iTestFD, pRes->ai_addr, pRes->ai_addrlen ) != 0 ) - bContinue = true; // skip this one, we can't use it - } - close( iTestFD ); - if( bContinue ) - continue; - } -*/ if( pRes->ai_family == AF_INET ) {