Why not have your server leave the port closed most of the time, and only open it when it has an active connection? That way programs on the local machine can use it when no remote users are connected.
Hmm. You may be onto something there! I could also add a webform, accessible only from localhost through a cgi-type interface, that would break any active connection(s) tying up the port.
Thanks for the idea! (And also for the code link!)