Interestingly the socket Client instances on the JS side are closing the socket when they get closed. This is wrong given that the ServerSocket is managing this connection. Whenever clients are attached to or removed from the same file descriptor, they should only invalidate the timer and the file descriptor. The socket itself still has to remain. Not sure if that is one cause why we have seen a couple of disconnects in the past for Mozmill 2.0, but the upcoming fix here will make the shutdown process more robust.
Looks like I was wrong here. PR_Close() indeed closes the connection for the client. It doesn't affect the file descriptor for the server. So that's not the problem, and I have to look further. Closing bug as invalid.