On Thu, 30 Dec 2010, amit paliwal wrote:

Please refer to below sample code as it is not working for me, please help
me find problem in it. I posted it in another thread also but not gettign
any response and it is very imp for me:

You posted that less than 24 hours ago. If you want faster answers than so, buy support from someone.

   curl_easy_setopt( ctx , CURLOPT_URL,  "http://localhost:4433"; ) ;
   curl_easy_setopt( ctx , CURLOPT_INTERFACE,  "127.0.0.1" ) ;
   curl_easy_setopt( ctx , CURLOPT_LOCALPORT, 4434 );

Can you please explain to us the logic and reason for these two latter options in combination with that URL?

   curl_easy_setopt(ctx, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);

HTTP 1.1 is default.

size_t write_data( void *buffer, size_t size, size_t nmemb, void *userp )
{
 int segsize = size * nmemb;

 CURL *ctx = (CURL*)userp;
 printf("\nCurl object address is:%p",ctx);
 CURLcode ret;

 curl_easy_setopt( ctx1 , CURLOPT_READDATA ,ctx);
 curl_easy_setopt( ctx1 , CURLOPT_READFUNCTION , readcb );
 curl_easy_setopt(ctx1, CURLOPT_CUSTOMREQUEST, "GET") ;
 *int ret = curl_easy_perform(ctx1);*

You can't call curl_easy_perform() from within the write callback on the same handle. That will either not work or cause chaos.

If you really want to do something from within the write callback then you need to understand what you're doing (the recursive nature and the fact that the first response will be "paused" there until the second request is completed) and you need to it with another curl handle.

--

 / daniel.haxx.se
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html

Reply via email to