I am using curl in my c++ program to retrieve a url from a web server on two different linux machines.
Before I try to get the URL I try to connect to the server initially using the below code.
I have the following options set:
Code:
CURLcode tResult = CURLE_OK;
curl_easy_setopt ( pstdEasy, CURLOPT_HTTPHEADER, pstdTransferData->pstdHeaders );
curl_easy_setopt ( pstdEasy, CURLOPT_HTTPGET, TRUE );
curl_easy_setopt ( pstdEasy, CURLOPT_NOBODY, TRUE );
curl_easy_setopt ( pstdEasy, CURLOPT_WRITEFUNCTION, OnReceiveHttpResponse );
curl_easy_setopt ( pstdEasy, CURLOPT_WRITEDATA, pstdEasy );
curl_easy_perform ( pstdEasy );
the content of pstdTransferData->pstdHeaders is as follows:
User-Agent: MyDeviceName
Content-Type: text/xml
Expect:
Accept: text/xml, text/html, application/xml
Connection: Keep-Alive
Accept-Language: EN
I have two linux machines each with identical software and apache webserver the only difference is that one of them is behind a NAT with port forwarding set up.
Machine A has an address of 80.20.30.1
Machine B has an address of 192.168.200.1 which is behind a NAT with an address of 80.20.30.2.
The problem is that when I try to connect to Machine B (Which is behind the NAT) I get the response to be
CURLE_GOT_NOTHING instead of
CURLE_OK which is what I get when I connect to Machine A.
What could be wrong here? Why is the call failing when the target is behind a NAT.
If you need any more info just ask.
Thanks
Harry