title: How can I distinguish read and write events on the same socket?
body: <p>I'm using <code>epoll</code> to get notifications about incoming data. It's not hard because all events returned by <code>epoll_wait()</code> indicates, that I can read data from <code>epoll_event.data.fd</code> (socket descriptor).</p>
  
  <p>But now I want get both types of notification: receiving and sending (socket is available for send). But I can't to do it because:</p>
  
  <ol>
  <li><code>epoll_event.events</code> which is returned by <code>epoll_wait()</code> is the same as I pass in <code>epoll_ctl()</code>. So it contains both <code>EPOLLIN</code> and <code>EPOLLOUT</code> in my case.</li>
  <li>Also if i trying to twice add one socket in <code>epoll</code> (as EPOLLIN and as EPOLLOUT event) I'll get a <code>EEXIST</code>.</li>
  </ol>
  
  <p>How can I solve this problem without manually calling <code>select()</code> every time I get notification?</p>