r/learnjava • • Sep 24 '19

Socket

Imagine i made java app with 2 class. Server and client. What i need to do if i want connect to my server using my app if i go to my neighbord house and on his computer? How do that?

1 Upvotes

3 comments sorted by

View all comments

3

u/Wolfhammer69 Sep 24 '19

Use your WAN IP's in the socket connections.

It really is no different than using LAN IP's for a local client/server, they are just endpoints, where they are physically doesn't mean much.

Make sure whatever port your using is allowed through your firewalls if you are using them and use NAT/open ports to point to the internal addresses as required for traffic on that port.

1

u/holle197 Sep 24 '19

Thanx . One more question i have: Do my app need have server together with client if i want run it from my neighbord computer?

1

u/Wolfhammer69 Sep 24 '19

Server running on one machine, and client running on the other typically. Client opens socket to server, they talk both ways.