How can I make c++ download something from internet to a folder? I've seen a dll made with c++ what downloads files but how can I do it?
How can I make c++ download something from internet to a folder? I've seen a dll made with c++ what downloads files but how can I do it?
it depends on the operating system. "sockets" is a good search term to start with though.
i seem to have GCC 3.3.4
But how do i start it?
I dont have a menu for it or anything.
There's lotsa ways, you're being incredibly vague. If you're on Windows and want very easy-to-use API's, you might check out the WinInet API with things like InternetReadFile or perhaps URLDownloadToFile. However, I think that connect()ing, send()ing a request and then recv()ing data from the socket would be a perfectly applicable choice for you. You can search the internet for something like a simple HTTP Get, and check out socket FAQ's, read Beej's socket tutorial, etc. I'm sure you'll find something to suit you.
Can you make me an example of it? Make me an example which dowloads a file to my computer. For example google logo.
Did you even try to look? An example of what? Okay well, Beej has graciously provided us with a stream socket example. It can be located here: http://www.ecst.csuchico.edu/~beej/g...l#simpleclient of course, this can be modified more than easily to fit winsock and the HTTP protocol. Simply start up winsock (WSAStartup()), and perform a send() of "GET /favicon.ico HTTP/1.1\r\nHost: meh.meh.meh\r\n\r\n" for example, and optionally, you could call inet_addr() before gethostbyname, as it is part of the Winsock Lame List. Again, this is only one example, and you never asked for which one to implement, and are again being vague. If you wanted to use InternetReadFile, look up InternetOpen, InternetOpenUrl, and then ReadFile API reference, it's almost identical in function. If you wanted URLDownloadToFile, well, it's incredibly simple, the callback is somewhat more difficult to implement though. A google search gets plenty of pretty nice results.
At least the MSDN function reference didn't explain anything... I dont even know the header file to be included...
So I need these headers: <netdb.h> <sys/types.h> <netinet/in.h> <sys/socket.h>
Where can i get them?
You can also use HTTP API
[C++]
IDE: DevC++ 4.9.9.2 (GCC 3.4.2)
2nd compiler: g++ (GCC 3.4.3/4.0.0)
3rd compiler: Borland 5.5
[C#]
IDE: Microsoft Visual C# Express 2005
2nd IDE: SharpDevelop
2nd compiler: csc in Command Prompt
.NET Framework: 2.0
[PHP]
Core: 5.1.0 beta 3
IDE: PHPEdit
2nd IDE: Notepad
Favourite extensions: exif,gd2,mysql
Favourite PEAR packages: DB, XML_RSS, ID3
Favourite databases: SQLite, MySQL
I looked there and that didnt explain anything
Maybe you should wait until you know more C++. You're probably wasting time just trying to skip to sockets, as you wont get the full benefit without knowing how to put it together in sensible/efficient ways.
The comments on the code on those sites is enough explanation needed when you know C++. Since you should know C++ before you move onto sockets it doesnt need to explain much, it just shows you which headers and which commands to use, then you look up the commands somewhere (MSDN, google, etc.) and put them together.
This is a simple tutorial on Winsocks, sort of like this sites C++ tutorials, so its easier to relate to: http://www.hal-pc.org/~johnnie2/winsock.html
Warning: Have doubt in anything I post.
GCC 4.5, Boost 1.40, Code::Blocks 8.02, Ubuntu 9.10 010001000110000101100101
>> You can also use HTTP API
Yeah I linked to that, it's called the WinInet API. It's kind of a dirty .......... but it's pretty cool I guess. I don't think you really gave a solid attempt to look for resources yourself, but if you want the utter most basic winsock tutorial in the world, MSDN has it, under the name "Getting Started with Winsock". The code is commented, all the functions ref's are linked and explained, and there is simply nothing more complex than a Hello World. Looky here: http://msdn.microsoft.com/library/de...th_winsock.asp
Last edited by Tonto; 08-22-2005 at 01:25 PM.
I had to chuckle at your request, maxorator, because what you're asking is a very tall request. It sounds like such a simple little favor, but you're asking for an "example" of something and that something happens to require someone to author the entire body of "your" program's primary functionality.Originally Posted by maxorator
You are obviously very new to C++ programming. You really must learn and familiarize yourself with the language and it's concepts before you jump into something as complicated as socket programming. However, if you insist on persisting, do a lot of reading to earn a better comprehension before you jump into the icy waters. Good luck.
Originally Posted by Tonto
that good link! thanks
I don't want to use it in any program, I just want to know how its done.Originally Posted by LuckY
Ok, first errorOriginally Posted by Tonto
[Linker error] undefined reference to `WSAStartup@8'
Another error
4 C:\Programs\Dev-Cpp\Templates\main6.cpp `main' must return `int'
Last edited by maxorator; 08-22-2005 at 11:45 PM.