The reason this occurs is that the port is still open. This is by design
given the flexibility of COMM-DRV/VxD. It
allows several processes to have access to the opened port and as such we do not
attach the port resource to any specific process. This should be taken into
account when you design your application.
COMM-DRV/VxD
assigns port IDs sequentially. The first port opened will
always be zero, the second 1, and so on. If only one application is using
COMM-DRV/VxD, then if the application crashes,
one needs to only pre-close the port open fails. A cleanup routine may look like
the following.
-
- #define MYMAXPORT
5
- void Cleanup()
- {
- for (VxDPId=0;VxDPId<MAX_PORTS;VxDPId++)
- WCSCVxDCleanup(VxDPId);
- }
If there may be more than one application running using
COMM-DRV/VxD, then the above routine would be
dangerous, as it will close ports in use by other apps, likely causing a crash.
This type of application might want to store the returned port ID in either the
registry or file and pre-close said port ID if a subsequent open fails.
|