title: How to read in a string over tcp socket in Swift
body: <p>If I have a java tcp server sending some text, how do I read that text from an <code>NSInputStream</code> and store it in a string?</p>
  
  <p>Here is a chunk of code I have, but I'm not really sure how to get a string from here:</p>
  
  <pre><code>NSStream.getStreamsToHostWithName(addr, port: port, inputStream: &amp;inp, outputStream: &amp;out)
  
  let inputStream = inp!
  let outputStream = out!
  inputStream.open()
  outputStream.open()
  
  var readByte :UInt8 = 0
  while inputStream.hasBytesAvailable {
      inputStream.read(&amp;readByte, maxLength: 1)
  }
  </code></pre>