cURL
Haxx ad
libcurl

curl's project page on SourceForge.net

Sponsors:
Haxx

cURL > Mailing List > Monthly Index > Single Mail

curlpp mailing list Archives

[cURLpp] edited telnet from Todd Papaionnou's simple curlpp

From: Julius Morales Reolizo <myst_frozenshadow_at_yahoo.com>
Date: Tue, 20 May 2008 20:56:02 -0700 (PDT)

I edited Todd Papaioannou’s simple
curlpp…
Why do I get Failed writing
body…
 
Sori if repost but I want to have a
simple connection on telnet with my script not curl’s script… If anyone can help
me plz do… I just a newbie on curlpp…
 
/***************************************************
 
#include
<string>
#include
<iostream>
#include
"curl/curl.h"
 
using namespace
std;
 
// Write any errors in
here
static char
errorBuffer[CURL_ERROR_SIZE];
 
// Write all expected data in
here
static string
buffer;
 
// This is the writer call back
function used by curl
static int writer(char *data, size_t
size, size_t nmemb,
                  std::string
*buffer)
{
  // What we will
return
  int result =
0;
 
  // Is there anything in the
buffer?
  if (buffer !=
NULL)
  {
    // Append the data to the
buffer
    buffer->append(data, size *
nmemb);
 
    // How much did we
write?
    result = size *
nmemb;
  }
 
  return
result;
}
 
// You know what this
does..
void
usage()
{
  cout << "curltest: \n"
<< endl;
  cout << " Usage: curltest
url\n" << endl;
}
 
/*
 * The old
favorite
 */
int main(int argc, char*
argv[])
{
 
  if (argc > 1)
  {
    string
url(argv[1]);
        
    cout << "Retrieving "
<< url << endl;
 
    // Our curl
objects
    CURL
*curl;
    CURLcode
result;
    
    // Create our curl
handle
    curl =
curl_easy_init();
 
    if
(curl)
    {
      // Now set up all of the curl
options
      curl_easy_setopt(curl,
CURLOPT_ERRORBUFFER, errorBuffer);
      curl_easy_setopt(curl,
CURLOPT_FAILONERROR,1);
      curl_easy_setopt(curl,
CURLOPT_URL,
"telnet://rainmaker.wunderground.com/");
      //curl_easy_setopt(curl,
CURLOPT_URL, argv[1]);
      curl_easy_setopt(curl,
CURLOPT_VERBOSE, 1);
      curl_easy_setopt(curl,
CURLOPT_WRITEFUNCTION, write);
      curl_easy_setopt(curl,
CURLOPT_WRITEDATA, &buffer);
      
 
      // Attempt to retrieve the
remote page
      result =
curl_easy_perform(curl);
 
      // Always
cleanup
      
curl_easy_cleanup(curl);
 
      // Did we
succeed?
      if (result ==
CURLE_OK)
      {
        cout << buffer
<< "\n";
        
exit(0);
      }
      
else
      {
        cout << "Error: ["
<< result << "] - " <<
errorBuffer;
        
exit(-1);
      }
    }
  }
}
**************************************/

      
_______________________________________________
cURLpp mailing list
cURLpp_at_rrette.com
http://www.rrette.com/mailman/listinfo/curlpp
Received on 2008-05-21

These mail archives are generated by hypermail.

donate! Page updated November 12, 2010.
web site info

File upload with ASP.NET