It seems vsmserver can exhaust the available low ports on a system when it is using them for connections to vsmagent. I noticed this because tlwebadm couldn't start because 1010 was already used.
We should start setting SO_REUSEADDR for these connections.
The async stuff made this rather difficult. Adding SO_REUSEADDR was easy, but then connect() fails instead as you can easily get a socket address collision if you already have an ongoing connection to that agent.
We need to either keep some global state so we know which ports to avoid, or make XMLRPCClientChannel capable of looping on a higher level so that it can catch the failed connect() and retry using another port.
The latter might be more appealing as we also have a bug in XMLRPCClientChannel where it doesn't try every response from getaddrinfo(), which it should as it is crucial to get good IPv6 behaviour.
Not doing this right now though, but a hackish version (bug 3878) instead.
This page discussed the same issue with regard to the LPD protocol:
We should look into setting SO_LINGER for the sockets as well.