Get the server's UDP port in client

Some refactoring