Retreiving a webpage with winsock

Started by
4 comments, last by Terminatore3 16 years, 9 months ago
Hello, I'm working on a multiplayer game and want to set it up to contact a webpage to retrieve the IPs of the current servers (I realize this is not the best method, but this is a low-profile game and I already have a free web host). I'm using winsock for my network and would like an easy method to basically open the webpage with my program and receive the same text my browser would receive. I have googled this for a few hours and have come up with nothing except some visual basic tutorials, but I am writing my program in C/C++ and do not know VB. Any help would be greatly appreciated. P.S. I would rather not use a library, this is mainly just an extra feature I want to add to the game and not so important I want to work with a library.
Advertisement
HTTP-GET isn't a library, as much as two C++ files that let you implement simple web page scraping.

If you are Windows only, you can use the built-in Internet Services. Look at WinHTTP on MSDN.
enum Bool { True, False, FileNotFound };
Well, I checked both of those out, they both look very good, but neither of them will compile for me. HTTP-GET I'm missing a header that I can't find. I'd prefer to use winhttp, but I'm missing the SDK for it and can't find it anywhere, from the looks of it, it's operating system dependent? Well, i'm running windows XP and my game should run on most windows systems, but i'll be content if it only runs on XP. Do you know where I can get the SDK for winhttp 5.1?
I imagine it's part of the Platform SDK for Windows, which you can download from MSDN. Typically, they call it "platform sdk for <latest OS version>" but it's actually usable for development for any version, as long as you stick to the rules for that version.

HTTP-GET is tested source code that you can use in your implementation, but it's not a full implementation -- you need to adjust it to your own needs. If there's something it uses that you don't have, you have to provide it, or take out the part that uses it.
enum Bool { True, False, FileNotFound };
All you need to do is set your socket to be 80, connect to the server, send a properly formatted request for a .txt file. It will then send you the file, chunk by chunk, which you can then use as you please.
Thanks for all your help guys. I actually found someone elses source code that they made themselves that they were having problems with and looking at the HTTP-get source I managed to fix it and use it for my own needs. Thank you very much, it works great now.

This topic is closed to new replies.

Advertisement