title: Client socket read "freezes"
body: <p>I want to write a simple web proxy, for exercise. Here's the code I have so far:</p>
  
  <pre><code>
  def g = new Proxy()
  g.serverPort = 9000
  println "starting"
  g.eachClient { Socket client ->
      println "got a client"
      try {
          client.withStreams { input,output ->
              String text = input.text
              println "received $text from client"
              client.close()
          }
      } catch(IOException io) {
          println "IO error. Probably client disconnected"
          //io.printStackTrace()
      }
  }
  </code></pre>
  
  <p>the thing is, the line :</p>
  
  <pre><code>String text = input.text</code></pre>
  
  <p>consumes all the available data in the Socket's InputStream. If the client isn't closing the connection, that method will just wait until it can read a end of file character ( if I remember correctly ). What do I have to prevent this from happening, and have the client's string available ASAP?</p>