Sign in to follow this  
Terminatore3

Retreiving a webpage with winsock

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this