Copy link to clipboard
Copied
hi every body
i just wana an exiplinantion about socket in AS3
this a java code for socket communication
Server Side | Client Side |
---|---|
serversocket s = new ServerSocket("ip",port); Socket client; while (true) { client = s.accept(); DataInptStream d =client.get ...etc DataOutptStrm o=client.getoutpt....etc read write methods } | Socket client=new socket(port); Dataoutptstrm SendtoServer=client.getoutpt... . . . etc |
i asked for an implementation for that , i read about but i couldn't understand how could it be
also if i have a java listeneer on a port,, could as3 socket connect to that port, i ment does dataoutpt streams in java will work with as3 sockets???
Copy link to clipboard
Copied
hi again
in AS3 we cannot build a server but i build a client
a java server runs above
and the client in AS3 is :
var client:socket=new socket();
client.connect("localhost",port);
client.addeventlistener(progressevent.socket_data,read);
function read(e:progressevent):void{
var t:string=e.readutf();
}
function snd(String tt){
if(Client.isconnected){
client.writeutf(tt)
}else{
client.connect("localhost",port);
snd(tt);
}
}