Hello everyone,

I am using the code in the following website (http://www.adp-gmbh.ch/win/misc/sockets.html#test) that is a ready Socket and Client class for connecting to a website. But in the Client.cpp code, if I put a query for Google instead of the host name in the send() method, I get a bad response.

s.SendLine("GET / HTTP/1.0");
s.SendLine("Host: www.google.com/search?hl=en&q=chair");
s.SendLine("");

does not work, and

s.SendLine("GET / HTTP/1.0");
s.SendLine("Host: www.google.com");
s.SendLine("");

works... And SendLine is just a call to send() in WinSock2.h.

Anyone has any ideas?

THANKS!

What is the response you are getting? I had a similar problem - I did not get a bad response - in fact the response string was telling me that I was connected. Turned out that the web-site I connected to used a cookie to maintain the session state. The second call immediately after the first send request returned the required result. Is that your problem?

Cheers,

Dieter

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.