title: Ruby TCPSocket communication
body: <p>I am learning TCPSocket and have a simple server written:</p>
  
  <pre><code>require 'socket'
  
  server = TCPServer.open(2000)
  
  loop {
    client = server.accept
    p client.gets
    client.print("bar")
    client.close
  }
  </code></pre>
  
  <p>and simple client written:</p>
  
  <pre><code>require 'socket'
  
  hostname = 'localhost'
  port = 2000
  socket = TCPSocket.open(hostname, port)
  
  socket.print("foo")
  p socket.gets
  </code></pre>
  
  <p>When I run these in separate terminals with either the server or client communicating one way (i.e. one "prints" and the other "gets") I get the expected string on the other side. When I run these as written, with the client first "print"-ing a message to the server and then the server "gets"ing it to then "print" a string to the client, it just hangs. What is causing this issue?</p>