Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jun 30th, 2006, 11:52 AM   #11
Wizard1988
Professional Programmer
 
Wizard1988's Avatar
 
Join Date: Oct 2005
Location: Chitown
Posts: 417
Rep Power: 4 Wizard1988 is on a distinguished road
Send a message via AIM to Wizard1988
I receive

After connecting
After connecting
HTTP/1.1 200 OK
Cache-Control: GET /index.html HTTP/1.1
Wizard1988 is offline   Reply With Quote
Old Jun 30th, 2006, 11:56 AM   #12
LOI Kratong
Professional Programmer
 
Join Date: May 2005
Location: Woo - Boot Sector!
Posts: 294
Rep Power: 4 LOI Kratong is on a distinguished road
OK, what IDE/Compiler are you using?
__________________
www.heldtogether.co.uk
LOI Kratong is offline   Reply With Quote
Old Jun 30th, 2006, 12:00 PM   #13
Wizard1988
Professional Programmer
 
Wizard1988's Avatar
 
Join Date: Oct 2005
Location: Chitown
Posts: 417
Rep Power: 4 Wizard1988 is on a distinguished road
Send a message via AIM to Wizard1988
I tested it in VS 6
Wizard1988 is offline   Reply With Quote
Old Jun 30th, 2006, 12:14 PM   #14
LOI Kratong
Professional Programmer
 
Join Date: May 2005
Location: Woo - Boot Sector!
Posts: 294
Rep Power: 4 LOI Kratong is on a distinguished road
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
LOI Kratong is offline   Reply With Quote
Old Jun 30th, 2006, 12:20 PM   #15
nnxion
Programming Guru
 
nnxion's Avatar
 
Join Date: Jun 2005
Location: elemental plane
Posts: 1,429
Rep Power: 5 nnxion is on a distinguished road
#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
nnxion is offline   Reply With Quote
Old Jun 30th, 2006, 12:27 PM   #16
LOI Kratong
Professional Programmer
 
Join Date: May 2005
Location: Woo - Boot Sector!
Posts: 294
Rep Power: 4 LOI Kratong is on a distinguished road
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
LOI Kratong is offline   Reply With Quote
Old Jul 2nd, 2006, 4:52 PM   #17
Game_Ender
Professional Programmer
 
Game_Ender's Avatar
 
Join Date: May 2006
Location: Maryland, USA
Posts: 306
Rep Power: 3 Game_Ender is on a distinguished road
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.
Game_Ender is offline   Reply With Quote
Old Jul 2nd, 2006, 6:00 PM   #18
Dameon
Troll
 
Dameon's Avatar
 
Join Date: Apr 2005
Location: Texas
Posts: 732
Rep Power: 4 Dameon is on a distinguished road
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
Dameon is offline   Reply With Quote
Old Jul 2nd, 2006, 6:08 PM   #19
Game_Ender
Professional Programmer
 
Game_Ender's Avatar
 
Join Date: May 2006
Location: Maryland, USA
Posts: 306
Rep Power: 3 Game_Ender is on a distinguished road
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
you will get a message about how google does not allow automated use of there services.
Game_Ender is offline   Reply With Quote
Old Jul 3rd, 2006, 7:53 PM   #20
Kilo
Expert Programmer
 
Kilo's Avatar
 
Join Date: Nov 2005
Location: In Pink Clam?
Posts: 542
Rep Power: 0 Kilo is an unknown quantity at this point
Send a message via AIM to Kilo
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
Kilo is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 6:52 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC