Connect to socket, read and write data

Hi.
Im playing around with a flash game idea of mine.
Trying to connect the flash file to my java socket server.
Having a few problems as it seems the flash file will not output data from the socket when i know its being written (well pretty sure atleast).

The java server recognizes the connection and sends a request for a password to the client but the private function handleData(msg) { does not seem to get this request.

What did i do wrong?
Heres my current class file

Thanks
//Woka
[AS]
package AS.socket{
import flash.errors.;
import flash.events.
;
import flash.net.Socket;

import AS.encryption.*;  

public class socketConnector2 {
    private var encrypter:rot; 
    public function socketConnector2(en:rot) {
        
        encrypter = en;
        
        var host:String="127.0.0.1";
        var port:int=9765;

        var connection=new Socket();
        connection.connect(host, port);
                    
        connection.addEventListener(Event.CLOSE, handleDisconnect);
        connection.addEventListener(Event.CONNECT, handleConnection);
        connection.addEventListener(ProgressEvent.SOCKET_DATA, handleData);
    }
    
    private function handleConnection(success) {
        trace("connected");
    }
    
    private function handleData(msg) {
        trace("Data: " + msg);
    }
    
    private function handleDisconnect() {
        trace("disconnected");
    }
}

}
[/AS]

P.S. if anyone would like to take the time to explain to me how i should send data to and from the client id be much obliged. I’ve heard its not good to send strings of the data…
was considering sending things like **/c 123.4 324.1 **to the server were the /c tells the server its a coordinate and the following two terms are the x and y coordinates. Whys that bad? (and if its bad what should i do?)