I created a simple AIR application that uses SocketMonitor to
check the availability of ports on the local machine. When I call
my function, I pass in the server name and the port (ex.
"localhost", 3306). This code works the first time I launch the app
(if MySQL is running, I get a true value. But if I stop the
service, nothing changes in my AIR app. The "available" property
always returns true. Also, if I try to set the pollInterval
property of SocetMonitor, the app crashes. I am using the following
public var socketAvailable:Boolean=false;
public var mysocket:SocketMonitor;
public function startPortCheck(serverName:String,
mysocket = new SocketMonitor(serverName,portNumber);
public function socketStatusChange(event:StatusEvent):void
trace( ">>onStatusEvent::evt.code=" + event.code );
socketAvailable = mysocket.available;
The monitors check when there is a NetworkStatusChange. If
you want more frequent checks, you should definitely use
pollInterval. I'm not able to reproduce a crash with pollInterval
& the SocketMonitor. What pollInterval have you tried? Is this
with localhost? Is it right away or eventually after a few polls?
What platform are you running?
One tiny thing though, you should .start() after the
.addEventListener. You want to make sure you catch all
dispatches...if you start before listening you could miss one.