Hi,
There is no better way if after you check whether the port is free you
immediately try to use it.
The two statements (check and use) won't execute as an atomic operation.
Therefore, it's possible that you'll check for the port being in use and it
will be "false", and then you'll try to acquire its use and an exception will
be thrown because another process slipped in before you.
So if you have to code for the exception handling anyway to account for the
lack of synchronicity, there is no reason to check the port's status in the
first place.
Why is try...catch inefficient for you?
--
Dave Sexton
"NoOne" <No**@none.comwrote in message
news:eh**********@news2.netvision.net.il...
Hi everybody!
I'm want to check if a certain port is opened or closed.
now I'm using try-catch to connect to the port. if it fails, it meas that
the port is closed.
The problem is that this method is extremely inefficient! anyone has a
better idea on how to do this kind of verification?
Thanks!