title: Why will socket connection to port 23 not work?
body: <p>I have this small test socket connection class:-</p>
  
  <pre><code>import java.net.Socket;
  import java.io.BufferedReader;
  import java.io.BufferedWriter;
  import java.io.InputStreamReader;
  import java.io.OutputStreamWriter;
  import java.io.IOException;
  
  public class TestTelnet {
  
  public static void main(String args[]) throws Exception {
      Telnet telnet = new Telnet(); 
      Socket socket = null ;
      socket = new Socket("localhost", 23);
      socket.setKeepAlive(true);
      BufferedReader r = new BufferedReader(new InputStreamReader(socket.getInputStream()));
  
          BufferedWriter w = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream()));
      System.out.println(r.readLine());
      socket.close();
  }
  }
  </code></pre>
  
  <p>It works perfectly well when I use another port (for example 25 for SMTP) and the println of r.readLine works brilliantly.  I can also connect to port 23 via the command prompt (telnet localhost 23) and I get the following returned:-</p>
  
  <p>Ubuntu 8.10
  my-laptop login: </p>
  
  <p>But when I try and connect to port 23 using my java class, it just hangs on the readLine println.  Does anyone know why this is? </p>