Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jul 15th, 2012  |  syntax: C  |  size: 0.32 KB  |  hits: 26  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1.        
  2. timeout.tv_sec = 3;
  3. timeout.tv_usec = 0;
  4.                
  5. FD_ZERO(&fds);
  6. FD_SET(sock_fd, &fds);
  7.        
  8. while(running) {
  9.         printf("Waiting for connect");
  10.  
  11.         if((result = select(32, &fds, NULL, NULL, &timeout)) == -1) {
  12.                 printf("select returned an error");
  13.                 return -1;
  14.         }
  15.                
  16.         if(result == 0) {
  17.                 printf("no connections");
  18.         }
  19. }