I'm trying to create a new socket, but it keeps finding a IO Exception, saying
Couldn't get the I/O for the connection to: localhost.
Here is my code snippet:
Socket mySocket = null;
BufferedReader in = null;
try{
mySocket = new Socket("localhost",4444);
in = new BufferedReader( new InputStreamReader(mySocket.getInputStream()));
} catch (UnknownHostException e) {
System.err.println("Don't know about host: localhost.");
System.exit(1);
} catch (IOException e) {
System.err.println("Couldn't get the I/O for " + "the connection to: localhost.");
System.exit(1);
}
I tried to change my hostname "localhost" to also my hostname for my computer (i.e. typing in hostname in cmd to find hostname). Also tried another port, but it all keeps giving me the same error. What are some tips or ways to debug this? Or can you pinpoint what the problem is? Thank you for your help.