cURL / Mailing Lists / curl-users / Single Mail

curl-users

crash in windows

From: Surya Kiran Gullapalli <suryakiran.gullapalli_at_gmail.com>
Date: Tue, 27 Jun 2006 09:45:07 +0530

Hi,
I'm a newbie to curl. I wrote a small program to download a webpage. The
sample code is working fine in linux. But on windows, i'm getting a
segmentation violation at curl_easy_perform.

Please find the sample code here.
===================
#include <curl/curl.h>
#include <iostream>
#include <string>
using namespace std ;

int main (void)
{
    CURL *curl ;
    CURLcode res ;

    string file ("staban.html") ;
    char error [CURL_ERROR_SIZE] ;

    FILE *fp ;
    fp = fopen (file.c_str(), "w") ;

    curl = curl_easy_init() ;
    if (curl)
    {
        curl_easy_setopt(curl, CURLOPT_URL, "http://www.google.co.in") ;
        curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp) ;
        curl_easy_setopt(curl, CURLOPT_VERBOSE, 1) ;
        curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, error) ;
        res = curl_easy_perform (curl) ;
        if (res)
        {
            cout << "******************************" << endl;
            cout << error << endl ;
            cout << "******************************" << endl;
        }
        curl_easy_cleanup(curl) ;
    }

    fclose(fp) ;
    return 0 ;
}
===========================
My network connection is thru proxy server. I did not explicitly set the
proxy information in the code, but during run time, i set those environment
variables on the command line and then run the program. As i've mentioned,
I'm getting a seg fault at curl_easy_perform on windows. What am i doing
wrong here?

Thanks in advance,
Surya
Received on 2006-06-27