No response from Google
I am making a program that uses winsock, it will be doing different things and one is getting webpages. Anyways I made it to connect to google to test it out and it sends the request for index.html but doesn't receive a response. I'm thinking it's something to do with returning the request. Like if you telnet to google's port 80 and type in "GET /index.html HTTP/1.1" you have to hit Enter/Return twice to send the request. This is how I made and sent my request to google:
I add the two '\r' to simulate the hitting enter twice like you have to in telnet. This doesn't invoke any response from google, and it should. I even tried it without the two carriage return characters('\r'). The request is successfully sent and everything, I don't think the lack of response has anything to do with my way of receiving it but I will post it anyways.
strcpy(request,"GET /index.html HTTP/1.1");
Any suggestions on why google doesn't respond? Thanks again.
Your logic is bjorked. settign 253-255 to \r\r\0 does nt affect the string since it ended awhile ago. So you have created:
"GET /index.html HTTP/1.1\0\0\0\0\0........\r\r\0"
Obviously this is not a valid request. strlen(request) gives you the lengthupto the first '\0'.
Secondly, HTTP takes \r\n as a new line, not \r\r. Read the HTTP RFC. Also, since the HTTP protocol takes two new lines, \r\n i sonly 1 new line by the specs stnadard so you need two of them.
Finally, why do you set the \r\r\0 with =? why not just do it in the strcpy? strcpy(..., "yadda\r\r");
Read the HTTP RFC.
Ok thanks this is what works:
Now it returns it's index web page.
strcpy(buffer,"GET /index.html HTTP/1.1 \r\n\r\n\0");