title: Redirect STDIN to socket and socket to STDOUT
body: <p>I am trying to develop a simple command-line client to the server. After I connect to the server and setup everything correctly I want to redirect <code>STDIN</code> to the socket connected to the server and the same socket to <code>STDOUT</code>. I want to achieve behavior similar to the of <code>nc</code> tool.</p>
  
  <p>The most simple solution would be use <code>select()</code> and use <code>read()</code>/<code>write()</code> to pass data from <code>STDIN</code> to the socket and from the socket to <code>STDOUT</code>.</p>
  
  <p>Is there any other simpler way to somehow connect socket to to the <code>STDIN</code>/<code>STDOUT?</code> I thought about using <code>dup2()</code> system call. However, I am not sure how to make it work.</p>
  
  <p>Thanks.</p>