Telnet connection on client or local machine
Is this code right - well it compiles but throws an error saying that "ConnectException:Connection refused" - how do I get round this, all I want to do is connect to Telnet on my computer (local). Surely it cant be that hard!!!
public static void main (String args[]) throws IOException {
{ try
{InetAddress ina = InetAddress.getLocalHost();
System.out.println(ina);
Socket s = new Socket(ina, 23);
BufferedReader in = new BufferedReader(new InputStreamReader(s.getInputStream()));
boolean more = true;
while (more)
{ String line = in.readLine();
if (line == null) more = false;
else
System.out.println(line);
}
}
catch (IOException e)
{ System.out.println("Error" + e);
}
}
}
}
[821 byte] By [
earnshaw1] at [2007-9-26 2:34:41]

To connect to a telnet port a server has to be listening on that port. Generally that would be a telnet server.
How you get a telnet server running depends on the OS.
Presumably you would already be aware of this on unix, so I will presume you are on windows.
With Win NT workstation, the telnet server is a service, which shows up in your services panel. If there start it. If not you need to install it. I think it is on one or more of the service paks, probably with the personal web server stuff (service pak 3.)
Win NT server (and 2000) it is part of the standard install.
With win 9x, I suspect you need to buy one or find a free one.
are you using windows NT? when I first started about 2 years ago trying that, I had to allow the connection permission on the local computer before that worked. check tosee if you are throwing a security exception.connection refused is tell tale, no server running sign though.