Reputation: 603
I am very confused. I cannot find a specific answer to my conundrum. I figured this applies to all languages, but I'm writing my application in Java specifically.
So, I am simply trying to connect two separate computers, which are running on the SAME network.
Computer 'A' is the server, and Computer 'B' is the client.
When the Client connects, I just want to display a message on the server.
My question: Is it possible to connect two PC's (one being the server, the other being the client), on the same network, without any kind of port forwarding, or other internet settings (with the exception of some firewall settings)? Also, what IP do you have to use to connect the two PC's?
Thank you very much!
Upvotes: 2
Views: 7846
Reputation: 533820
You don't need port forwarding. All you need to do on the server is something like
ServerSocket ss = new ServerSocket(KNOWN_PORT);
while(running) {
executor.submit(new SocketHandler(ss.accept()));
On the client side
Socket s = new Socket(KNOWN_HOST, KNOWN_PORT);
Upvotes: 2