Changeset View
Changeset View
Standalone View
Standalone View
mod/util/http.c
Context not available. | |||||
static int | static int | ||||
connect_server( const char *server, ushort port, unsigned int flags ) | connect_server( const char *server, ushort port, unsigned int flags ) | ||||
{ | { | ||||
int sock=-1,srv,srvcount=0,connected=0; | int sock=-1,srv,srvcount=0,connected=0,hostfound=0; | ||||
struct srventry *srvlist=NULL; | struct srventry *srvlist=NULL; | ||||
#ifdef _WIN32 | #ifdef _WIN32 | ||||
Context not available. | |||||
for(ai=res;ai;ai=ai->ai_next) | for(ai=res;ai;ai=ai->ai_next) | ||||
{ | { | ||||
hostfound=1; | |||||
if((sock=socket(ai->ai_family,ai->ai_socktype,ai->ai_protocol))==-1) | if((sock=socket(ai->ai_family,ai->ai_socktype,ai->ai_protocol))==-1) | ||||
{ | { | ||||
log_error("error creating socket: %s\n",strerror(errno)); | log_error("error creating socket: %s\n",strerror(errno)); | ||||
Context not available. | |||||
if((host=gethostbyname(srvlist[srv].target))==NULL) | if((host=gethostbyname(srvlist[srv].target))==NULL) | ||||
continue; | continue; | ||||
hostfound=1; | |||||
if((sock=socket(host->h_addrtype,SOCK_STREAM,0))==-1) | if((sock=socket(host->h_addrtype,SOCK_STREAM,0))==-1) | ||||
{ | { | ||||
log_error("error creating socket: %s\n",strerror(errno)); | log_error("error creating socket: %s\n",strerror(errno)); | ||||
Context not available. | |||||
if(!connected) | if(!connected) | ||||
{ | { | ||||
#ifdef _WIN32 | #ifdef _WIN32 | ||||
log_error("%s: host not found: ec=%d\n",server,(int)WSAGetLastError()); | if (hostfound) | ||||
log_error("%s: cannot connect: ec=%d\n",server,(int)WSAGetLastError()); | |||||
else | |||||
log_error("%s: host not found: ec=%d\n",server,(int)WSAGetLastError()); | |||||
#else | #else | ||||
log_error("%s: host not found\n",server); | if (hostfound) | ||||
log_error("%s: cannot connect\n",server); | |||||
else | |||||
log_error("%s: host not found\n",server); | |||||
#endif | #endif | ||||
if(sock!=-1) | if(sock!=-1) | ||||
sock_close(sock); | sock_close(sock); | ||||
Context not available. |