Allow server to listen on a dynamically-chosen port

If the server's listen method is called with listenport=0, the OS will automatically select a port. This is useful for embedding the server in a script that might have multiple concurrent instances. However, there's currently no simple way to determine the port the server is listening on after it starts.

This branch makes two small changes to make this possible: the server's listenport attribute is set from the socket after it has been bound; and a threading.Event is added so other threads can wait for the listenport to be updated.