title: Will setting a timeout on a socket work if you are reading a full line using a buffered reader?
body: <p>I'm writing a socket client that sends a line down a socket connection and then waits for up to 45 seconds for a line back from the server.</p>
  
  <p>I'm using a buffered reader like so:</p>
  
  <pre><code>Socket socket = null;
  PrintWriter out = null;
  BufferedReader in = null;
  try {
              socket = new Socket(host, 800);
              out = new PrintWriter(socket.getOutputStream(), true);
              in = new BufferedReader(new InputStreamReader(
                                          socket.getInputStream()));
  } catch (UnknownHostException e) {
              listener.failedToConnectToHost(e);
              return;
  } catch (IOException e) {
              listener.failedToConnectToHost(e);
          return;
  }
  
          BufferedReader stdIn = new BufferedReader(
                  new InputStreamReader(System.in));
          out.println("message");
  try {
          String response = in.readLine();
          listener.responseRecived(response);
          return;
  } catch (IOException e) {
          listener.errorReadingResponse(e);
          return;
  }
  </code></pre>
  
  <p>If I add the following line (Or something like it)</p>
  
  <pre><code>socket.setSoTimeout(45000);
  </code></pre>
  
  <p>What will happen after 45 seconds assuming that nothing has come through from the other end?</p>
  
  <p>I assume I'll be catching an interrupted exception but I'm sure?</p>
  
  <p>Will this even work? The docs for setSOTImeOut() imply that it's socket.read() that will timeout, I assume that the buffered reader is calling this somewhere down the stack, but assumption is the mother of all screw ups, so I just wanted to check.</p>