Jump to content
  • Advertisement
Sign in to follow this  
RandomPixel

Communication with server

This topic is 3648 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
Advertisement
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

i would check by telnetting to a webserver but vista does not come with it by default, so i can not confirm atm.

Share this post


Link to post
Share on other sites
I found out the problem. He was using the wrong socket when receiving data. It works if I change the socket to the server socket. :)

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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!