This worked for me. Right now you can just call connectSocket() from a page script, but you can dissect it and make it work with your configuration.
var socket_A;
var receivedData = "";
function connectSocket()
{
socket_A = new TCPSocket(false);
socket_A.onConnect = function()
{
System.print('Connected !');
label = 'connected';
socket_A.write('GET /pictures/unes/clones-home.jpg HTTP/1.0\r\n');
socket_A.write("HOST:www.macgeneration.com\r\n\r\n");
};
socket_A.onData = function()
{
System.print('Receving !');
receivedData += socket_A.read();
System.print(receivedData);
};
socket_A.onError = function(e)
{
System.print('On IOError !');
System.print(e);
};
socket_A.onClose = function()
{
System.print('On Close !');
// remove the HTTP information from the received data
var imageStartIndex = receivedData.indexOf("\r\n\r\n");
var bitmapData = receivedData.substring(imageStartIndex+4);
// make and display the image
var MyImage = new Image(bitmapData);
GUI.widget("output").setImage(MyImage);
};
socket_A.connect('[Link: macgeneration.com]);
}