Reputation: 1
When I used
InetAddress addr = InetAddress.getByName("192.168.1.104");
listen_socket = new ServerSocket(port,5,addr);
then it works fine
But when use dynamic ip
InetAddress addr = InetAddress.getByName("114.143.95.69");
listen_socket = new ServerSocket(port,5,addr);
the following error will be thrown
Error: Cannot assign requested address: JVM_Bind
What should I do to resolve the problem?
Upvotes: 0
Views: 2583
Reputation: 311039
Your dynamic IP is the address of your router, not an IP address belonging to an NIC of the localhost.
Use "0.0.0.0", or a null InetAddress, for that parameter.
Upvotes: 2