cubicalmonkey
asked on
Flash / Actionscript How to set socket timout()
I'm sure this is an easy question but I just cant seem to make it with with my junior AS3 skills.
Trying to figure out how to set the timeout on a binary socket connection.
Basically what I'm looking to do is attempt to reconnect to my socket if the first connection fails.
From what I've read and experience, the default socket time out is 20 seconds which is much too long for me.
Id like to set this to say, 5 seconds.
Hoping this resolves some of the flash "error #2048" problems I'm seeing.
Thanks for your help!
Trying to figure out how to set the timeout on a binary socket connection.
Basically what I'm looking to do is attempt to reconnect to my socket if the first connection fails.
From what I've read and experience, the default socket time out is 20 seconds which is much too long for me.
Id like to set this to say, 5 seconds.
Hoping this resolves some of the flash "error #2048" problems I'm seeing.
Thanks for your help!
function startTest():void{
Tbytes = 0;
ExternalInterface.call( "updateStatus","Preparing download test");
connectToSocket();
stop();
}
function connectToSocket():void{
s = new Socket(host, 7890);
s.addEventListener(IOErrorEvent.IO_ERROR, showError);
s.addEventListener(Event.CLOSE, closeHandler);
s.addEventListener(Event.CONNECT, connectHandler);
s.addEventListener(ProgressEvent.SOCKET_DATA, handleTcpData);
s.addEventListener(SecurityErrorEvent.SECURITY_ERROR,securityError);
}
var connCounter :Number = 0;
function securityError(event:Event):void {
if(connCounter < 4){
Security.loadPolicyFile("http://"+host+"/crossdomain.xml");
connectToSocket();
}else{
ExternalInterface.call("logError","securityError:-Counter:"+connCounter + feedback,stripspaces(event.toString()));
}
connCounter ++;
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for you help !