Connecting to socks server

Alright im trying to connect to my friends socks server he has set up just to see if i can send something. The code below is an .as file and then my .fla file has import Name;

I did this because i was getting the nesting error and people said that is how you fix it. Well after doing that it publishes ok and everything but my info never gets sent to my friends server. His server is up and running so that is not the problem.

import flash.net.Socket;
import flash.events.Event;

class Test {

    static var sock:flash.net.Socket;

    static function onConnect(e) {
        trace("Connected!");
        sock.writeUTFBytes("Hello world
");
    }
    static function main() {
        trace("Creating socket");

        sock = new flash.net.Socket();
        sock.addEventListener(flash.events.Event.CONNECT, onConnect);
        try {
            sock.connect("xx.xxx.xxx.xx", xxxx);
            trace("is connected? " + sock.connected);
        } catch (e:Dynamic) {
            trace("Error in connect: " + Std.string(e));
        }
        sock.close();
    }
}

I have read the FAQ and went through 3 pages of AS3 forums before posting this. Im going mad here trying to figure it out. Please if you have any tips or suggestions feel free to post them.