[futurebasic] the port status check

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : May 2004 : Group Archive : Group : All Groups

From: Kris Rutecki <kris@...>
Date: Fri, 28 May 2004 13:55:57 -0400
>How do I check for an open port?

I tried to do just that (check the port status) 6 years ago and found that
you can't do it on a mac, without actually opening the port. Prior to OsX
the open call would fail once the port was already in use...
There are 2 things that you might want to consider:

1. Write your own open and close routines which are the only ones that use
your flag. Say:
 MyOpen sets the flag gPortOpen to non zero value when it is succesful. (it
would still use the normal FB OPEN C function. <- use the on error goto, to
ensure smooth operation when the port can't be opened...)
MyClose calls the CLOSE routine only when gPortOpen is not zero. Clears
gPortOpen to zero before returning.

2. Use the "On error goto" before you execute the CLOSE statement.
Once the error gets detected (that's when your port is already closed) you
should be able to handle it: Clear the OS Error, return.
The next statement after a close should be an "on error return" which passes
the error handling back to "System".

I hope this helps...
Kris