Improve port detect on client side