You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by am...@apache.org on 2008/01/22 13:19:02 UTC
svn commit: r614188 -
/xerces/c/trunk/src/xercesc/util/NetAccessors/WinSock/BinHTTPURLInputStream.cpp
Author: amassari
Date: Tue Jan 22 04:19:00 2008
New Revision: 614188
URL: http://svn.apache.org/viewvc?rev=614188&view=rev
Log:
Fixed compilation error when IPv6 support was enabled
Modified:
xerces/c/trunk/src/xercesc/util/NetAccessors/WinSock/BinHTTPURLInputStream.cpp
Modified: xerces/c/trunk/src/xercesc/util/NetAccessors/WinSock/BinHTTPURLInputStream.cpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/util/NetAccessors/WinSock/BinHTTPURLInputStream.cpp?rev=614188&r1=614187&r2=614188&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/util/NetAccessors/WinSock/BinHTTPURLInputStream.cpp (original)
+++ xerces/c/trunk/src/xercesc/util/NetAccessors/WinSock/BinHTTPURLInputStream.cpp Tue Jan 22 04:19:00 2008
@@ -331,49 +331,6 @@
//
// Set up a socket.
//
-#ifdef WITH_IPV6
- struct addrinfo hints, *res, *ai;
-
- memset(&hints, 0, sizeof(struct addrinfo));
- hints.ai_family = PF_UNSPEC;
- hints.ai_socktype = SOCK_STREAM;
- char tempbuf[10];
- XMLString::binToText(portNumber, tempbuf, 10, 10);
- int n = wrap_getaddrinfo(hostNameAsCharStar,(const char*)tempbuf,&hints, &res);
- if(n<0)
- {
- hints.ai_flags = AI_NUMERICHOST;
- n = wrap_getaddrinfo(hostNameAsCharStar,(const char*)tempbuf,&hints, &res);
- if(n<0)
- ThrowXMLwithMemMgr1(NetAccessorException, XMLExcepts::NetAcc_TargetResolution, hostName, fMemoryManager);
- }
- SOCKET s;
- for (ai = res; ai != NULL; ai = ai->ai_next) {
- // Open a socket with the correct address family for this address.
- s = wrap_socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
- if (s == INVALID_SOCKET)
- continue;
- if (wrap_connect(s, ai->ai_addr, ai->ai_addrlen) == SOCKET_ERROR)
- {
- wrap_freeaddrinfo(res);
- // Call WSAGetLastError() to get the error number.
- ThrowXMLwithMemMgr1(NetAccessorException,
- XMLExcepts::NetAcc_ConnSocket, urlSource.getURLText(), fMemoryManager);
- }
- break;
- }
- wrap_freeaddrinfo(res);
- if (s == INVALID_SOCKET)
- {
- // Call WSAGetLastError() to get the error number.
- ThrowXMLwithMemMgr1(NetAccessorException,
- XMLExcepts::NetAcc_CreateSocket, urlSource.getURLText(), fMemoryManager);
- }
- SocketJanitor janSock(&s);
-#else
- struct hostent* hostEntPtr = 0;
- struct sockaddr_in sa;
-
bool sawRedirect;
int redirectCount = 0;
SOCKET s;
@@ -381,6 +338,50 @@
bool lookUpHost = true;
do {
+
+#ifdef WITH_IPV6
+ struct addrinfo hints, *res, *ai;
+
+ memset(&hints, 0, sizeof(struct addrinfo));
+ hints.ai_family = PF_UNSPEC;
+ hints.ai_socktype = SOCK_STREAM;
+ char tempbuf[10];
+ XMLString::binToText(portNumber, tempbuf, 10, 10);
+ int n = wrap_getaddrinfo(hostNameAsCharStar,(const char*)tempbuf,&hints, &res);
+ if(n<0)
+ {
+ hints.ai_flags = AI_NUMERICHOST;
+ n = wrap_getaddrinfo(hostNameAsCharStar,(const char*)tempbuf,&hints, &res);
+ if(n<0)
+ ThrowXMLwithMemMgr1(NetAccessorException, XMLExcepts::NetAcc_TargetResolution, hostName, fMemoryManager);
+ }
+ if (janSock.get())
+ janSock.release();
+ for (ai = res; ai != NULL; ai = ai->ai_next) {
+ // Open a socket with the correct address family for this address.
+ s = wrap_socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
+ if (s == INVALID_SOCKET)
+ continue;
+ if (wrap_connect(s, ai->ai_addr, (int)ai->ai_addrlen) == SOCKET_ERROR)
+ {
+ wrap_freeaddrinfo(res);
+ // Call WSAGetLastError() to get the error number.
+ ThrowXMLwithMemMgr1(NetAccessorException,
+ XMLExcepts::NetAcc_ConnSocket, urlSource.getURLText(), fMemoryManager);
+ }
+ break;
+ }
+ wrap_freeaddrinfo(res);
+ if (s == INVALID_SOCKET)
+ {
+ // Call WSAGetLastError() to get the error number.
+ ThrowXMLwithMemMgr1(NetAccessorException,
+ XMLExcepts::NetAcc_CreateSocket, urlSource.getURLText(), fMemoryManager);
+ }
+ janSock.reset(&s);
+#else
+ struct hostent* hostEntPtr = 0;
+ struct sockaddr_in sa;
if (lookUpHost &&
((hostEntPtr = wrap_gethostbyname(hostNameAsCharStar)) == NULL))
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xerces.apache.org
For additional commands, e-mail: commits-help@xerces.apache.org