kurumkan
kurumkan

Reputation: 2725

Why can't access server via public ip

I am playing with simple client - server app on Java. I have 2 computers. 1st one(server) is on ubuntu, the second is windows8(client). Both machines connected to the same net, same router. When I create socket on client via "short" ip - like this

            socket = new Socket(InetAddress.getByName("192.168.1.7"),4444);

it works well - no issues. But when I am trying do like this -

        socket = new Socket(InetAddress.getByName("95.188.199.188"),4444);

which uses public ip(as I understand). The latter one - doesn't work. Firewall - turned off. What is the problem?

Upvotes: 0

Views: 716

Answers (3)

Haroldo_OK
Haroldo_OK

Reputation: 7230

Regardless of firewall, the Internet will always see your router, not your local machine; you will have to configure your router to forward the desired port to the correct local machine.

Upvotes: 2

CESCO
CESCO

Reputation: 7758

Try 0.0.0.0. Its all the available interfaces.

Upvotes: 0

Guillaume Barré
Guillaume Barré

Reputation: 4218

Because if you are inside your internal network, you cannot use the public IP.

This is usally due to the default configuration of the router. The router won't use public IPs to resolve "internal" request.

Upvotes: 4

Related Questions