user2098268
user2098268

Reputation: 121

Java Connect Over A Socket Using Public IP Address

I'm basically trying to connect to other computer. Everything works as I want once I use "localhost" as the IP address. If I try to put in my public IP, my client cannot find the server running although it is. If I switch it to "localhost" it works again.

I'm using a router or a modem or how do you call these things to split internet for 4 people + wireless. I have my port forwarded, but I still can't get it to work. What are the problems I might be encountering? I don't think this is the problem with the code since everything works properly with "localhost", unless I need to do something extra when switching to public IP.

I also tried to disable firewall and it still didn't work. When I checked what is my IP address it is said that my IP is static, but I don't see the difference.

Any thoughts/ideas are much appreciated.

Upvotes: 0

Views: 1856

Answers (2)

user2098268
user2098268

Reputation: 121

I have found my problem. I was doing everything correctly. And everything works correctly. The problem is that my router can't connect to itself using my static(external/public) IP. Other people can connect to my external/public IP properly.

Upvotes: 0

Chris
Chris

Reputation: 1426

There are two possible problems I can think of:

  1. You didn't forward your ports correctly, or there's some other problem with your router configuration. In that case, your question is better asked on Superuser.
  2. Your server is listening only on your loopback interface. Make sure in your server code you have it set to listen on 0.0.0.0, or whatever your library/OS equivalent is.

Upvotes: 1

Related Questions