HTTP, Sockets, and Stuff

I’m trying to understand sockets and HTTP. I understand that sockets is a method of communicating over a network. And this is how browsers work, and HTTP is a standard form of this communication used by browsers. I’m trying to replicate this in flash to better understand these sorts of things and perhaps come up with something useful. I’ve gotten this working with PHP using the following code.

<?php
$http_response = ‘’;
$fp = fsockopen(google.com’, 80);
fputs($fp, "GET / HTTP/1.1
");
fputs($fp, "Host: google.com

");
while (!feof($fp)){
$http_response .= fgets($fp, 128);
}
fclose($fp);
echo nl2br(htmlentities($http_response, ENT_QUOTES, ‘UTF-8’));
?>

But I cannot replicate it using flash sockets. When I run it from the testing environment I get a connect but no data sent and the connection is closed immedietly. And when trying to run it locally, or off a local web server I get nothing. My code is below, can anyone help?

var sock:XMLSocket = new XMLSocket();
sock.addEventListener(Event.CONNECT, onConnect);
sock.addEventListener(DataEvent.DATA, onData);
sock.addEventListener(Event.CLOSE, onClose);
sock.addEventListener(IOErrorEvent.IO_ERROR, onError);
sock.connect(“handyspoon.com”, 80);
function onConnect(e:Event):void{
trace(“connected”);
textBox.appendText("connected
");
sock.send("GET / HTTP/1.1
");
sock.send("Host: handyspoon.com

");
}
function onData(e:DataEvent):void{
trace(“data”);
trace(e.data);
textBox.appendText(e.data);
}
function onClose(e:Event):void{
trace(“close”);
textBox.appendText("close
");
}
function onError(e:IOErrorEvent):void{
trace(e.text);
textBox.appendText(e.text);
}
stop();