You are not logged in.
I am a beginner in Socket Programming. I am trying to do some simple stuff but had a basic query.
I would like to implement something like wget in C top of a TCP socket (i.e., without using any HTTP libraries). Just provide a URL (Example-- $wget www.foo.com/bar.pdf) on the command line, construct a HTTP GET request to download the file identified by the URL, and download and save the file.
Right now trying this only for static HTTP content.
Can someone point out how to begin? What are the steps involved?
Thanks in advance.
I assume this is just for learning purposes? Because, for real-world app use, you'd
almost definitely be better off using a ready-built library that speaks HTTP for you,
such as libcurl...
Then, it's just a matter of creating a TCP socket, connecting to the host and port (80
by default for "http:" URLs) from the URL, and sending the appropriate GET request
with appropriate HTTP headers, and then reading and parsing the reply...