title: Find out if the socket was accepted or not
body: <p>I have basic example of using <code>poll()</code> method:</p>
  
  <pre><code>struct pollfds fds[5];
  int nfds = 1;
  
  fds[0].fd = listen_sd;
  fds[0].events = POLLIN;
  
  while(1) {
      int ret = poll(fds, nfds, 0);
  
      if (ret &lt; 0) {
          exit(1);
      }
  
      int size = nfds;
  
      for (int i = 0; i &lt; size; i++) {
          if (fds[i].revents == 0) {
              continue;
          }
  
          if (fds[i].revents != POLLIN) {
              exit(1);
          }
  
          if (fds[i].fd == listen_sd) {
              // Something happened on the server
              // If there is a client which wasn't accepted yet, it returns its fd
              int new = accept(listen_sd, null, null);
              // If there is a client which was already accepted,
              // it doesn't return anything, just loop in accept() method
  
          } else {
              // Something happened on a different socket than the server
          }
      }
  }
  </code></pre>
  
  <p>All messages from clients will flow through server socket.</p>
  
  <p>It means there is always something happened on the server socket, isn't it?</p>
  
  <p>But how can I do something like this (in true condition):</p>
  
  <ul>
  <li><p>Try to accept a socket, some function should return: the socket is already
  accepted, the socket hasn't been accepted yet.</p></li>
  <li><p>When the socket is already accepted - receive the data.</p></li>
  <li><p>When the socket hasn't been accepted yet - accept the socket and
  receive the data.</p></li>
  </ul>