I am trying to write a function to determine if a port is
open on a remote server. I would like to do this within ColdFusion.
See below for what I have come up with so far
The problem I have with this method is that on failer it
takes 20 seconds to return. I have found methods using
InetSocketAddress that allows you to set a timeout but that does
not seem to be available within ColdFusion
I am certainly not stuck on Sockets if there another method
that will work.
if you don't set the timeout either via setSoTimeout() or
doing a connect() it defaults to 0, which is infinity. the
setSOTimeout is used during reads so i guess you want the connect
method. see if this code works any better.
btw your socket connect can fail for any number of reasons,
not just timeout. if you specifically want to trap timeouts you ned
to catch java.net.SocketTimeoutException.