Advertisement

Winsock and files...

Started by May 24, 2005 05:33 PM
3 comments, last by hplus0603 19 years, 8 months ago
I was wondering if it is possible to read something like, say, a text file from a URL using Winsock? If so, how? Sorry if this is a dumb question, but I'm still new to the whole network and internet programming thing. Thanks!
-----------------------------Play Stompy's Revenge! Now!
Quote:
Original post by Stompy9999
I was wondering if it is possible to read something like, say, a text file from a URL using Winsock? If so, how? Sorry if this is a dumb question, but I'm still new to the whole network and internet programming thing.

Thanks!


1. Connect to the website using a TCP socket on port 80.
2. Use the HTTP GET command to retreive the file. You send a formated string to the webserver and read back the result. Since it's all printable text (some characters have to be escaped/translated), it's relatively easy to figure out/debug.

Example program. I don't use VB, but it's a quick example found with google.

Here is perhaps a better example. See the GetHTTP*.zip files (there a few).
Advertisement
Thanks again, John!
-----------------------------Play Stompy's Revenge! Now!


Hi,

Another viable option is Microsoft's WinInet API. It's really quite easy to setup an utilize. You can quite easily create special headers and all the rest.

Later,

GCS584
If you want portable code, try HTTP-GET. That ought to work both on WinSock and Linux.
enum Bool { True, False, FileNotFound };

This topic is closed to new replies.

Advertisement