Skip to main content
Inspiring
June 9, 2006
Answered

Determine if a port is open on Remote Server

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.

I am using CF 7 on Server 2003

Thanks
This topic is closed to new replies. Start a new post to keep the conversation going.
MudockSRCorrect answer
Inspiring
June 10, 2006
That seems to work exactly as I hoped.

Thanks!

2 replies

Inspiring
June 10, 2006
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.
Translate
MudockSRAuthorCorrect answer
Inspiring
June 10, 2006
That seems to work exactly as I hoped.

Thanks!
Translate