How does java detect locally available port numbers? The following method is invalid. Ports 5000 and are occupied, but the port will still be reported as valid.
Don't use the new InetSocketAddress (host, port); , directly use new InetSocketAddress(port));); , the host uses.
0.0.0.0 or 127.0.0. 1 cannot be used.