简体   繁体   中英

Java ServerSocket binding to port Hamachi

So I've been working on a small application that would allow me to create a server, have the server connect/bind to a hamachi network/port, and allow the client to join the hamachi server, then use the client application to communicate and other such things over the server.

There is no good documentation that I've been able to find in the last 4 hours that specifies how to do this. I have a basic Server application that works fine on the "localhost" , but I really want to make it work over hamachi.

code example:

  InetAddress addr = InetAddress.getByName("**.***.***.***"); ServerSocket sSocket = new ServerSocket(****, 5, addr); 

The error received is:

Error: java.net.BindException: Cannot assign requested address: JVM_Bind

I am using netbeans, and yes, I am 100% positive that the port is NOT in use. Please help!

Just specify null as the third argument to the constructor. That means 'listen at all local IP addresses'.

I suspect the IP address you're trying to bind to isn't local. You can't do that.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM