maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   General (https://talk.maemo.org/forumdisplay.php?f=7)
-   -   What Is The Use Of libconic Api And How libconic and curl Http Are realted (https://talk.maemo.org/showthread.php?t=34808)

kamesh.smartdude 2009-11-20 07:30

What Is The Use Of libconic Api And How libconic and curl Http Are realted
 
Hai All,

I read abt libconic api and i don't understand how it is usuful to access the intenet.

i understand that if an application want to use the internet(to select the IAP) we must use the libconic api.

Then only we can get info from the webpage using curl http.

My Openion is correct or wrong?

libconic is the only monitor to internet connections?

is ConIcConnection pointer is used in curl http?

thanks and regards
kamesh.smartdude.

naabi 2009-11-20 07:49

Re: What Is The Use Of libconic Api And How libconic and curl Http Are realted
 
I'm not an expert of the Maemo APIs (haven't used any lol), but to my knowledge libconic provides a way to handle your connections even if user is switching between e.g. 3G, GSM and WLAN.

lardman 2009-11-20 09:01

Re: What Is The Use Of libconic Api And How libconic and curl Http Are realted
 
yes, libconic is used to handle connections (setup, switch, shutdown). It has nothing to do with curl. For curl you do something like this:

CURL *curl;
CURLcode res;
curl = curl_easy_init();
curl_easy_setopt(curl, CURLOPT_URL, url);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)&resultchunk);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, curl_writebuffer);
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1);
res = curl_easy_perform(curl);
curl_easy_cleanup(curl);

Obviously you'll want some error checking in there too ;)

lardman 2009-11-20 09:01

Re: What Is The Use Of libconic Api And How libconic and curl Http Are realted
 
// Following fn from liq*, thanks Gary/lcuk
static size_t curl_writebuffer(void *ptr, size_t size, size_t nmemb, void *data)
{
struct curl_memorybuffer *mem = (struct curl_memorybuffer *) data;
int realsize = size * nmemb;

printf("In memory write callback, size=%d\n", realsize);

mem->memory = (char *)realloc(mem->memory, mem->size + realsize + 1);
if (mem->memory){
memcpy(&(mem->memory[mem->size]), ptr, realsize);
mem->size += realsize;
mem->memory[mem->size] = 0;
}
return realsize;
}

kamesh.smartdude 2009-11-23 13:06

Re: What Is The Use Of libconic Api And How libconic and curl Http Are realted
 
Quote:

Originally Posted by lardman (Post 383609)
yes, libconic is used to handle connections (setup, switch, shutdown). It has nothing to do with curl. For curl you do something like this:

CURL *curl;
CURLcode res;
curl = curl_easy_init();
curl_easy_setopt(curl, CURLOPT_URL, url);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)&resultchunk);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, curl_writebuffer);
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1);
res = curl_easy_perform(curl);
curl_easy_cleanup(curl);

Obviously you'll want some error checking in there too ;)

In maemo to use curl is it necessary to start the connection using libconIC api ?

Is There Any reference document or any examples to access internet using both libconIC and curl?

Markus 2009-11-24 22:10

Re: What Is The Use Of libconic Api And How libconic and curl Http Are realted
 
Quote:

In maemo to use curl is it necessary to start the connection using libconIC api ?
No, not on the n800 at least. You can start your connection manually using the maemo UI. Once a connection has been established, your application should be able to use curl to send HTTP requests.

Quote:

Is There Any reference document or any examples to access internet using both libconIC and curl?
I'm not sure but there are some libcurl examples here

http://curl.haxx.se/libcurl/c/example.html

And some Maemo4 linconIC examples here

http://maemo.org/maemo_release_docum...00000000000000

Perhaps the easiest thing to do would be to start the connection manually using the maemo UI for the time being and to concentrate on getting libcurl to work in your application. Once this is working you can integrate libiconic

Code:

mem->memory = (char *)realloc(mem->memory, mem->size + realsize + 1);
Is there not a memory leak here, if realloc fails?


All times are GMT. The time now is 20:19.

vBulletin® Version 3.8.8