Connecting Java sockets over wifi?

Viewed 1822

I am trying to make a simple messaging program using javafx and the java.net package. Right now I have a client class and server class that connect using serversocket and client socket on a random port. It works if I run both on the same computer or run them on different computers as long as both are connected to the same wifi and I specify the ip address.

However, it does not work if the two computers are not connected to the same wifi. How do I make it so that it works? Sorry, I am new to java.net and networking.

1 Answers
Related