Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)

Paste

Pasted as JavaScript by None ( 15 years ago )
import flash.net.Socket;
import flash.events.Event;
import flash.events.DataEvent;
import flash.events.IOErrorEvent;
import flash.events.SecurityErrorEvent;

class TCPClient extends Socket {
    
    public function new() {
        super();
        
        this.addEventListener(Event.CONNECT, onConnect);
        this.addEventListener(Event.CLOSE, onClose);
        this.addEventListener(DataEvent.DATA, onData);
        this.addEventListener(IOErrorEvent.IO_ERROR, onIOError);
        this.addEventListener(SecurityErrorEvent.SECURITY_ERROR, onSecurityError);
        this.connect('10.42.43.10', 44405);
    }
    
    private function onConnect(event : Event) {
        trace('onConnect: ' + event);
        this.writeUTF('Hello!');
    }
    
    private function onClose(event : Event) {
        trace('onClose: ' + event);
    }
    
    private function onData(event : DataEvent) {
        trace('onData: ' + event.data);  
    }
    
    private function onIOError(event : IOErrorEvent) {
        trace('onIOError: ' + event);
    }
    
    private function onSecurityError(event : SecurityErrorEvent) {
        trace('onSecurityError: ' + event);
    }
    
}

class GI {
    
    static function main() {
        new TCPClient();
    }
    
}

 

Revise this Paste

Your Name: Code Language: