0
votes

I'm testing my server using GNetLib for my networking on my computer. Whenever I use the IP of my network, it won't let my bind.

GNetServer netserver = new GNetServer(ServerConstants.HOST, ServerConstants.PORT);
    netserver.addEventListener(new ServerEventListener() {

       //random stuff not related to problem
    });

    netserver.bind();

My host is "76.5.43.21" // Not posting my actual IP but you get the gist. The port is 43594, and I've already tested the connection using canyouseeme.org and it says success.

Here is the full error:

java.net.BindException: Cannot assign requested address: JVM_Bind
at java.net.DualStackPlainSocketImpl.bind0(Native Method)
at java.net.DualStackPlainSocketImpl.socketBind(DualStackPlainSocketImpl.java:106)
at java.net.AbstractPlainSocketImpl.bind(AbstractPlainSocketImpl.java:382)
at java.net.PlainSocketImpl.bind(PlainSocketImpl.java:190)
at java.net.ServerSocket.bind(ServerSocket.java:375)
at java.net.ServerSocket.<init>(ServerSocket.java:237)
at org.gnet.server.GNetServer.bind(GNetServer.java:98)
at org.ott.Server.main(Server.java:91)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134)

Is the problem that I'm using my home networks IP, or is the the library limiting the IP I can use?

1

1 Answers

0
votes

You can only use an IP address that is local to the current host. You can't use an IP address that lives on the other side of a modem, router, etc. I would just bind to 0.0.0.0, which is an InetAddress of null in Java: then you're listening at any interface, and the router will take care of port forwarding, if you have it set up correctly.