Click here to Skip to main content
15,893,486 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
SQL
Write a C program that connects to a given Webserver, and downloads a given Webpage hosted
by the server. For simplicity, assume the Webpage is a static, pure HTML page.
Posted
Comments
[no name] 12-Oct-14 17:34pm    
And what is the question? What have you tried? What is the problem with the code you have written?

1 solution

Its not hard

a) set up a socket - for which you'll need host, page & port (maybe these can be passed as parameters) - about 11 lines of code
b) issue a connect using the socket from (a) - 1 line of code
c) [edit - whoops, its a web server you're speaking to] you may need to write a GET [path] HTTP/1.0 and a HOST statement to the socket
d) read the data that comes back from the socket - 2 lines of code can cover (d & e)
e) either write the results from (d) to a file or stdout
f) close and tidy up - 2-3 lines of code

Without comments, its about 20-30 lines of code

we arnt going to write your homework/assignment for you
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900