views:

108

answers:

3

i have a C code that parses a file and generates another file for the processed data. i now need to send these files to a web server (website). i guess there way is to do a HTTP POST. but i have never done this in c (Linux gcc compiler in ubuntu). Does anyone know how to do this. i need to a starting point as i have no clue of doing this in C.

i also need to be able to authenticate with the website.

+8  A: 

libcurl is probably a good place to start.

Hank Gay
+1 libcurl is the best!
George Edison
can you point me to any tutorials that get me started with libcurl. the first thing is how to download and use libcurl in a simple c code.
sfactor
http://curl.haxx.se/libcurl/c/libcurl-tutorial.html
Joe
+1  A: 

I think Hank Gay's suggestion of using a library to handle the details is the best one, but if you want to "do it yourself", you need to open a socket to the web server and then send your data in the HTTP POST format which is described here. Authentication can mean a variety of different things, so you need to be more specific.

Unfortunately, all of the above three jobs involve a fair bit of complexity, so you need to break the question down into stages and come back and ask about each bit separately.

Kinopiko
A: 

Here's an example of posting data via libcurl. A word of warning: I had a difficult time using libcurl on windows. Worked fine with PHP, but not easy to compile with C.

Abbas