cURL / Mailing Lists / curl-library / Single Mail


Mulit Interface is not working with proxy

From: penugonda chenna reddy <>
Date: Wed, 2 Apr 2008 16:54:23 +0530

The below code is working fine without proxy. If I enable proxy code by
Uncoomenting the proxy setopts code
The code is failing to connect to proxy. I am using curl 7.18.0 version.

I am not able to figure out what could be the problem. Someone can help me
in resloving this issue that will be of great help.

Thanks in advance,
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <curl/curl.h>
#include <io.h>
void* buffer;
size_t length;
CURLM *handler;
static size_t read_callback(void *ptr, size_t size, size_t nmemb, void
       return length;

size_t sicfwrite(void* data,size_t len)
       buffer = data;
       length = len;
       int handles;
        curl_multi_perform(handler, &handles));
        return len;
int main(void)
  CURL *curl;

  CURLcode res;
  handler = curl_multi_init();

  curl = curl_easy_init();
  if(curl) {
    /* First set the URL that is about to receive our POST. */
    curl_easy_setopt(curl, CURLOPT_URL,
    /* Now specify we want to POST data */
    curl_easy_setopt(curl, CURLOPT_POST, 1);

    /* we want to use our own read function */
    curl_easy_setopt(curl, CURLOPT_READFUNCTION, read_callback);

    /* get verbose debug output please */
    curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);

   curl_easy_setopt(curl, CURLOPT_HTTPPROXYTUNNEL, TRUE);
    curl_easy_setopt(curl, CURLOPT_PROXY, "");
    curl_easy_setopt(curl, CURLOPT_PROXYPORT, 8080);
    curl_easy_setopt(curl, CURLOPT_PROXYUSERPWD, "rastoa:temp1234!");
    curl_easy_setopt(curl, CURLOPT_PROXYAUTH,
    curl_multi_add_handle(handler, curl);

      If you use POST to a HTTP 1.1 server, you can send data without
      the size before starting the POST if you use chunked encoding. You
      enable this by adding a header like "Transfer-Encoding: chunked" with
      CURLOPT_HTTPHEADER. With HTTP 1.0 or without chunked transfer, you
      specify the size in the request.

      curl_slist *chunk = NULL;

      chunk = curl_slist_append(chunk, "Transfer-Encoding: chunked");
      res = curl_easy_setopt(curl, CURLOPT_HTTPHEADER, chunk);
      /* use curl_slist_free_all() after the *perform() call to free this
         list again */

sicfwrite((void*)"CHENNA REDDY",10);
sicfwrite((void *)"BANGALORE",9);
sicfwrite((void*) "AMIT RASOGI",6);
int i;
scanf("%d", &i);
sicfwrite((void*) "after getch",10);

sicfwrite((void *) "last record",0);

sicfwrite((void *) "last record",10);
    /* always cleanup */
        curl_multi_perform(handler, &handles))
  return 0;
Received on 2008-04-02