Please, can you give me simple example how to do GET requests with gtkmm.
I already tried to find answer in official documentation, but it didn`t help me.
I think i need to use libsoup or Webkit, but I don't know how to start.
You need to use some C++ network library. Look into curl or curlpp, you can even use WinSOCK if you are on Windows.
Related
I would also like to have an opportunity to add/modify HTTP GET headers, but basically I just need to download a page with given URL.
P. S. The only reason I'm searching for an alternative to libcurl is it doesn't give me the kind of download speeds I need.
Poco C++ has a HTTPClient class that is fairly easy to use. Here is their Networking tutorial. Poco C++ is also cross platform.
Here are some boost like recommendations from SO.
EDIT : If you haven't looked at Qt, they have a QNetworkRequest class. Seems a bit lower level than the Poco client, but might suit your needs. Here is an example using it.
To add to the other answers, if you target only Windows you can use the the urlmon functions (included in Windows), like URLDownloadToFile or URLOpenBlockingStream.
libwww looks like it might fit what you are looking for.
What to learn to be able to send files online using c++ on windows ?
i know c++, and i got a program that does some benchmark and saves into a text file, i want that text file to be sent to me after the benchmarking is done, so what should i search for ? tried searching found something called sockets and something about server and clients in linux, kinda dunno what to search for.
this isn't a homework, just want to do it for fun xD, and would help me in future if i want someone who knows nothing about whats happening to test something for me (the file would have all i need and it will be sent to me).
I think you better off just emailing the file after a benchmark is done, and doing it using some bash or Python scripting rather than C++ or any other low level language. Here is an example of sending email using Python. Another option would be to upload to the FTP or use rsync to transfer file over SSH. And in any case, do not write your own client-server application for this.
If you still want to use C++, here is an example of sending email using POCO.
you will find some official documentation on Win32 sockets here:
http://msdn.microsoft.com/en-us/library/ms738545%28v=vs.85%29.aspx
This tutorial seems pretty good and simple:
http://johnnie.jerrata.com/winsocktutorial/
Have a nice day!
I was told I have to use winsock, but I dont know where to start. For example, I am trying to access, lets say http://www.newegg.com/, I am trying to get the text title of just the three front page products. Any help is greatly appreciated. :D
I'd also recommend libcurl for this sort of thing.
You can use the cURL command line tool to generate sample code as well, which is helpful for experimentation.
W3.org themselves provide sample C / C++ librarys for Http requests.
Find them here
Specifically, look for HTTPReq.c
Use boost library and poco. They both provide solutions for network programming. Boost also provide spirit library which you can use for parsing data from websites. Poco libraru also provides NetSSL, crypto solutions.
P.S. boost::spirit is not a library for parsing data from websites, it provides solution for parsing strings ...
you need to open a socket.
then you need to do an http get
somewhat like :-
http://www.esqsoft.com/examples/troubleshooting-http-using-telnet.htm
You could use the QNetworkAccessmanager class from Qt framework.
I'm assuming you need to use c++ for a reason, such as integration with existing software, otherwise, as per some of the other suggestions, choosing a language with a more convenient framework (eg: scripting language) would be better suited for the task.
If you would like to avoid getting your hands dirty with WINSOCK, or have the need to run on a platform other than windows, you could look at the using the boost asio library.
The following page contains links to simple sync and async http clients:
http://www.boost.org/doc/libs/1_37_0/doc/html/boost_asio/examples.html
You can find documentation on the library itself at:
http://www.boost.org/doc/libs/1_37_0/doc/html/boost_asio.html
Use c++ if you must, but it might be a lot less painful to use python.
Look at the Python httplib module for how to set the host you want to pull from etc. Python's available for free for most platforms and is enough like C++ that you can probably learn python a heck of a lot faster than you can learn to write a program controlled browser in c++. Well, maybe that's not true for everyone on this site, but I'll bet it's true for "most" of us. I used to get stock quotes updated in near real time from CNN Money years ago and IIRC it was around 100 lines of python code.
Hotei
I have read about Thrift while trying to find out how to use Google Protocol Buffers. I have been searching for some reference that shows how to go about using it with a simple working example for C++. It's been frustrating not being able to find any such site. It is a bit surprising that almost all the examples use Java, a language that has cross-platform RMI already at its disposal. May be I have missed something in searching, and I would very much appreciate if anyone can give a reference to a tutorial with a working example, however small.
TIA,
-Sviya
I've never used Thrift, but Googling for "thrift" brought me to this page - http://incubator.apache.org/thrift/ - which has a C++ example at the bottom of the page.
The thrift wiki has this page - http://wiki.apache.org/thrift/ThriftUsageC%2B%2B - which has more info on using it with C++
Also,
once when you install thrift in folder tutorial you have example of thrift file,
server&client implementations in different languages and README file.
This is good place to start!
Because there were no tutorial on the web, I created one in my blog.
You can check my full tutorial about Thrift in: My Blog
Since it's too long, I cannot post my answer here. But I think my blog is a good resource for anyone who wants to get started with Thrift.
Does anyone have some sample code showing how to POST to a URL using wxWidgets? The documentation and discussion forums imply that it's possible but the methods in wxHTTP are very low-level compared to what you find in .NET and scripting languages like Perl and Ruby. Do I actually have to create the HTTP request myself and send it to the server via the SocketOutputStream? Am I missing something?
I came across a similar problem initially and ended up using Curl instead as it's also cross platform and is very easy to use.
Tim
Atually, same here. Tried using wxHTTP and ended up using Curl. And Curl is a charm to work with...
J-O