i'm trying to right a tcp chat program i have it set up so that you can choos to be either the server or the client
the server is set up like this:
ServerSocket srvr = new ServerSocket(port);
Socket skt = srvr.accept();
and the client is set up like this:
Socket skt = new Socket(ipAdress,port);
It works running both on one computer using port 12345 and ip "localhost", and it works over internet using port 12345 and my public ip. But for it to work over the internet i had to set up my router to forward port 12345 to my computer running the server.
how do i make it so that the program opens up a user defined port and forwards it to the server computer, so that users of the program only have to know the public ip of the server and the port. I don't know if that's how its supposed to work but that was what i was thinking. Thanks.