title: Non-blocking TCP socket handling - How to detect blocking state prior to writing on to the socket?
body: <p>I'm currently writing a proxy application that reads from one socket and writes on another. Both are set as non-blocking, allowing multiple sockets pairs to be handle.</p>
  
  <p>To control a proper flow between the sockets, the application should NOT read from the source socket if the writing on the target socket may block.
  The idea is nice, however I found no way to detect a blocking state of the target socket without first writing to it... and that is not what is needed.</p>
  
  <p>I know of an option to use <code>SIOCOUTQ</code> (using <code>ioctl()</code>) and calculate the remaining buffer, but this seems ugly compared to a simple check if the target socket is ready for writing.</p>
  
  <p>I guess I can also use <code>select()</code> for just this socket, but that is so much waste of a such heavy system call.</p>