Welcome Guest (Log in)

Checking for an open server port

StarStarStarStarStar
Internet (7) | Database (6) | Networking (4) |
General
Expander triangle
  • Author
  • Rating
  • Type
  • Revision
  • Downloaded
  • Updated
  • Devin Asay
  • StarStarStarStarStar
  • Snippet
  • 1
  • 2936 Times
  • 09 November 2009
Checking for an open server port
I have several Rev apps that store data on networked MySQL databases. If I happen to be in a network environment where the port I need to access is blocked (as some restrictive public WiFi's do), or if I just lose my internet connection, any revOpenDatabase function call will hang for a long time before it times out and reports a failure. So I worked out a way to check for an open port to the server, using a shell call to netstat, that doesn't hang my app. Instead, if the port is not available it is gracefully reported in just a few seconds without hanging Rev. I think the technique could be adapted to other, similar calls that block Rev while waiting for a timeout failure. I've only tested it on OS X and Win XP.
Ajax Loader
Tags
Expander triangle
User Comments
Expander triangle