So here is my situation. I need to use sockets when creating connections between server and client. It is impossible to agree. I have a server that is running and listening using something like this
ServerSocket serverSocket = new ServerSocket(portNumber); while (listening) { new MultiClientThread(serverSocket.accept()).start(); }
and I need a client to connect to the "portNumber" that is listening. The problem is that I use this line of code for the client.
Socket socket = new Socket(hostName, portNumber);
And I do not know how to get the "hostName" part for the parameters. Is it possible to get "hostName" if I knew the port number that they were listening to? Or maybe another way of saying this is how I can connect to a server listening on a port using tcp connections.
source share