[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Actionscript Socket Connection

Posted on 2011-05-03
13
Medium Priority
?
421 Views
Last Modified: 2012-05-11
Hi,

I want the flash movie to keep trying to connect to the server, so in the case if the server is offline, the client will connect whenever the server get online.

Additionally, I want it to do the same if it got disconnected for any reason.

I am using Actionscript 3 Socket class.
0
Comment
Question by:Mohamed Abowarda
9 Comments
 
LVL 39

Expert Comment

by:blue-genie
ID: 35514895
Hi, I don't know of any built in way to do this but why don't you use a timer to check at a specified interval whether socket connected - if not call the connect? not sure how efficient this will be in terms of processing but it should work if you don't find another way to do it.
0
 
LVL 29

Expert Comment

by:dgofman
ID: 35696494
You can use NetworkMonitoring but its available if you will run your SWF on AIR
0
 
LVL 12

Author Comment

by:Mohamed Abowarda
ID: 35696502
@dgofman: I must run the swf on a website.

I want the page to be connected all the time and if the server is offline it keep trying to connect till the server come online.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 29

Accepted Solution

by:
dgofman earned 2000 total points
ID: 35872197
You can try to loop with timeout by ping Google.com

var request:URLRequest = new URLRequest();
request.method = "HEAD";
request.url = "http://www.google.com";
var urlLoader:URLLoader = new URLLoader();
urlLoader.addEventListener( HTTPStatusEvent.HTTP_STATUS, connectHttpStatusHandler );
urlLoader.addEventListener( IOErrorEvent.IO_ERROR, connectErrorHandler );

private var interval:Number;
interval  = setInterval(recheckInternetConnection, 5000);

function recheckInternetConnection():void{
    urlLoader.load( request);
}

function connectHttpStatusHandler( event:HTTPStatusEvent):void{
     clearInterval(interval);
     trace(“CONNECTED”);
}
0
 
LVL 12

Author Comment

by:Mohamed Abowarda
ID: 35872214
@dgofman: I am using Socket class, basically, I want to the socket to keep trying to connect until it establish the first connection.
0
 
LVL 29

Assisted Solution

by:dgofman
dgofman earned 2000 total points
ID: 35872217
The same idea, expect instead
urlLoader.load( request);
you will use
socket.connect(host, port);


http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/Socket.html
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 36131076
I've requested that this question be deleted for the following reason:

This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0
 
LVL 29

Expert Comment

by:dgofman
ID: 36131077
I am waiting an author responce
0
 
LVL 12

Author Closing Comment

by:Mohamed Abowarda
ID: 36132024
It's working.

Thanks,
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Australian government abolished Visa 457 earlier this April and this article describes how this decision might affect Australian IT scene and IT experts.
This article will show how Aten was able to supply easy management and control for Artear's video walls and wide range display configurations of their newsroom.
Viewers will learn key ranges in Sampler to make their sampled instruments sound more realistic Gather samples of various notes and drag them to Key Range panel: Set proper root key for each sample: Select all the samples with Command-A (or Ctrl…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Suggested Courses
Course of the Month20 days, 6 hours left to enroll

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question