Advertisement
Guest User

Untitled

a guest
Jul 17th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.50 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <windows.h>
  3. #include <winsock2.h>
  4.  
  5. #define STDIN 0
  6.  
  7. int main(void)
  8. {
  9.     WSADATA wsaData;
  10.     WSAStartup(MAKEWORD(2,2), &wsaData);
  11.  
  12.     struct timeval tv;
  13.     fd_set readfds;
  14.  
  15.     tv.tv_sec = 5;
  16.     tv.tv_usec = 0;
  17.  
  18.     FD_ZERO(&readfds);
  19.     FD_SET(STDIN, &readfds);
  20.     select(STDIN+1, &readfds, NULL, NULL, NULL);
  21.  
  22.     if (FD_ISSET(STDIN, &readfds))
  23.         printf("input\n");
  24.     else
  25.         printf("timed out\n");
  26.  
  27.     WSACleanup();
  28.     return 0;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement