Sign in to follow this  

Communication with server

This topic is 3462 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm trying to connect to a web server and retrieve the html document from it by using the sample from Ultimate Game Programming: http://www.ultimategameprogramming.com/zips/Cpp_SimpleTextBrowser.ZIP But when I try to run it, it's not working. I receive -1 when trying to receive the data. Could someone tell me what's wrong? I'm using Microsoft Visual C++ 2003 when compiling it.

Share this post


Link to post
Share on other sites
put a break point in the start of the code and step through it, see if you can follow what is happening, it will probably show you where the fault lies.\

Share this post


Link to post
Share on other sites
I did that, and I saw that the received bytes is -1. Which means that the receive method didn't work. The connection seems to work, but I don't receive any data.

The application is sending "GET / HTTP/1.0\n\n" to the web server, and then receives data from the server. But it looks like the server don't send anything back. Is the command "GET / HTTP/1.0\n\n" still correct way to receive HTML data?

Share this post


Link to post
Share on other sites
Quote:
Original post by RandomPixel
Is the command "GET / HTTP/1.0\n\n" still correct way to receive HTML data?
No. You need \r\n, not \n. And most servers will need a Host: parameter. I always send:

GET / HTTP/1.0\r\n
Host: www.gamedev.net\r\n
\r\n

Share this post


Link to post
Share on other sites

This topic is 3462 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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