All pastes #944831 Raw Edit

Miscellany

public cpp v1 · immutable
·published 2008-03-16 13:49 UTC
rendered paste body
#include "socket.h"#include "networkstream.h"#include <stdio.h>#include <string>using namespace std;int main(int argc, char *argv[]){	try 	{		Socket s(PF_INET, SOCK_STREAM, 0);		s.Connect("www.google.com", 80);		NetworkStream ns(&s);				char buf[] = "GET / HTTP/1.1\nHost: www.google.com\n\n";				ns.Write(buf, sizeof(buf));				char readbuf[10240];						while(true)		{			memset(readbuf, 0, sizeof(readbuf));			ns.Read(readbuf, sizeof(readbuf));				printf("Data received:\n%s\n", readbuf);		}					}	catch(Exception e)	{		printf("An exception was unhandled at %s: \n%s\n", e.Location().c_str(), e.Message().c_str());	}}