On 1/29/2015 4:32 AM, Praveen Pvs wrote:
Is there way to just check the connection status of server? I need to
know the connection status of the server before posting the actual
data. If connection with server is available, then post the data to
the server otherwise dont post.
I have written the following function to check the connection: All the
required parameters are set to the curl handler before passing to this
function
What do you mean by the connection status? From your client to the
server or from the server to some backend? If you just want to see if
the server is up I think a fast way would be HEAD or OPTIONS. Neither is
going to work in every single case. I don't think there is a generic
catch all.
I am testing this function with various servers to which i need to
post the data. one server was returning CURLE_OK for curl_easy_perform
function and CURLINFO_RESPONSE_CODE as 200 (which i considered as
success), but one more server was returning
22(CURLE_HTTP_RETURNED_ERROR) for curl_easy_perform function and
CURLINFO_RESPONSE_CODE as 404.
So for connection status currently you are retrieving target page on
servers and get a 200? And in the case of one server you get 404 and
it's not. It sounds like your program is doing what you intended, no?
I tried to use CURLINFO_HTTP_CONNECTCODE instead of
CURLINFO_RESPONSE_CODE with the second server, i have received 0 for
the CURLINFO_HTTP_CONNECTCODE. I am not sure whether this value can be
considered as success.
CURLINFO_HTTP_CONNECTCODE is to get the proxy's response if you are
tunneling via CONNECT which would happen with an https connection or if
you have enabled CURLOPT_HTTPPROXYTUNNEL. It is not for a backend server
proxy but a proxy between your client and the server, ie client <->
proxy <-> server
Could you please help me to make it generic to test the connection
status of the server?
I doubt it but someone may come up with something if you give more detail.
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html