What would lead connect() to fail and return "Network unreachable"? What I'm trying to do is send a brief msg through port 80 to www.nerrenvirons.org from inside my firewall. I can websurf there, traceroute there, etc.., so as far as I can tell, the network CAN be reached. However whenever I execute this code, I always get "Network unreachable".
Both destination and source are running Apache -- but that means port 80 MUST be open, since I can http://www.nerrenvirons.org, right?
Here's my code. Any ideas??
Now when I set a break-point right before connect is called, these are the values, which SEEM to make sense:
//now open a socket to homebase so we can transmit the data
if ((sock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0)
Log("While trying to open a socket to home base, it failed");
} //end if
//resolve our hostname into a host struct to get the IP address
struct hostent *hostStructure = gethostbyname(repositoryURL);
//construct the server address structure
memset(&ServerAddress, 0, sizeof(ServerAddress)); // zero out the structure to begin with
ServerAddress.sin_family = AF_INET;
ServerAddress.sin_addr.s_addr = inet_addr(hostStructure->h_addr_list); //just try the first address
ServerAddress.sin_port = htons(repositoryPort);
JString msg = "GET blah";
Log("Sending this to home base: " + msg);
// now establish the actual connection to home base
if (connect(sock, (struct sockaddr *) &ServerAddress, sizeof(ServerAddress)) < 0)
Log("Connect failed - " + (JString)strerror(errno));
} //end if
hostStructure.h_aliases = "www.nerrenvirons.org"
ServerAddress.sin_addr = 4294967295
NOTE: www.nerrenvirons.org sites behind a proxy server called grampus.marisys.com.
Any ideas?? Thanks for any help.