![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#11 |
|
Professional Programmer
|
I receive
After connecting After connecting HTTP/1.1 200 OK Cache-Control: GET /index.html HTTP/1.1 |
|
|
|
|
|
#12 |
|
Professional Programmer
Join Date: May 2005
Location: Woo - Boot Sector!
Posts: 294
Rep Power: 4
![]() |
OK, what IDE/Compiler are you using?
__________________
www.heldtogether.co.uk |
|
|
|
|
|
#13 |
|
Professional Programmer
|
I tested it in VS 6
|
|
|
|
|
|
#14 |
|
Professional Programmer
Join Date: May 2005
Location: Woo - Boot Sector!
Posts: 294
Rep Power: 4
![]() |
I have DevC++ (the newest one). I wonder why we have the discrepancies, I take it you're on Windows with VS...
I'm sure we're missing something really small and obvious!
__________________
www.heldtogether.co.uk |
|
|
|
|
|
#15 |
|
Programming Guru
![]() Join Date: Jun 2005
Location: elemental plane
Posts: 1,429
Rep Power: 5
![]() |
#include <iostream>
#include <winsock2.h>
int main()
{
WSADATA wsaData;
int iResult = WSAStartup(MAKEWORD(2,2), &wsaData);
if(iResult != NO_ERROR)
std::cout << "Error at WSAStartup()" << std::endl;
SOCKET m_socket;
m_socket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
if(m_socket == INVALID_SOCKET)
{
std::cout << "Error at socket(): " << std::endl << WSAGetLastError();
WSACleanup();
return 1;
}
sockaddr_in server;
server.sin_family = AF_INET;
server.sin_addr.s_addr = inet_addr("64.233.167.99");
server.sin_port = htons(80);
if(connect(m_socket, (SOCKADDR*) &server, sizeof(server)) == SOCKET_ERROR)
{
std::cout << "Failed to connect." << std::endl;
WSACleanup();
return 1;
}
int bytesSent;
int bytesRecv = SOCKET_ERROR;
char sendbuf[] = "GET /imghp HTTP/1.0\n\n";
char recvbuf[1024] = "";
memset(recvbuf, 0, sizeof(recvbuf));
send(m_socket, sendbuf, strlen(sendbuf), 0);
for(;;)
{
bytesRecv = recv(m_socket, recvbuf, sizeof(recvbuf)-1, 0);
if(bytesRecv > 1)
{
recvbuf[bytesRecv] = '\0';
std::cout << recvbuf;
}
else
break;
}
closesocket(m_socket);
return bytesRecv;
}
__________________
"Employ your time in improving yourself by other men's writings, so that you shall gain easily what others have labored hard for." -- Socrates |
|
|
|
|
|
#16 |
|
Professional Programmer
Join Date: May 2005
Location: Woo - Boot Sector!
Posts: 294
Rep Power: 4
![]() |
Wow, thanks nnxion, I'll have to scan through it and see how it works though.
Cheers for the input guys!
__________________
www.heldtogether.co.uk |
|
|
|
|
|
#17 |
|
Professional Programmer
Join Date: May 2006
Location: Maryland, USA
Posts: 306
Rep Power: 3
![]() |
On another note, if you make http requests to google it won't give you back data unless you are (or say you are a browser). You have to the proper information in the outgoing http header. The firefox live httpheaders extension is a great way to find this out, because I happen to forget exactly what google wants.
|
|
|
|
|
|
#18 |
|
Troll
Join Date: Apr 2005
Location: Texas
Posts: 732
Rep Power: 4
![]() |
Google doesn't require any headers at all, just a basic request. I don't recall that any request headers are required by the spec.
GET / HTTP/1.1 And two linebreaks. You can easily try this with a telnet client. On a side not, the LiveHTTPHeaders extension is very useful, as is a packet sniffer such as Ethereal or Ettercap. Sometimes you may find something interesting...such as this header returned by Slashdot X-Bender: nogoodlawsprotectingtheinnocent-- It appears to also be random: X-Bender: Why would God think in binary?
__________________
MD5(sig) = bcef75433db02e9ad9bf81d6f7c5c270 |
|
|
|
|
|
#19 |
|
Professional Programmer
Join Date: May 2006
Location: Maryland, USA
Posts: 306
Rep Power: 3
![]() |
I am pretty sure they will not return any search results to a client that does not have a user-agent string identifing itself as a brower. It will work for the main page, but if you try the a query like
http://www.google.com/search?&q=automated |
|
|
|
|
|
#20 |
|
Expert Programmer
|
so far google is the only problem? I doubt he will run across that problem much.
__________________
"When in Rome, Do as the Romans Do" "Beauty is in the eye of the BEER holder" "Save your breath your going to need it for your blow up doll later" SearchLores.org |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|