/* 
   Temporizator utilizind select() 
   
   Adaptare dupa D.Comer & D.Stevens - "Internetworking with TCP/IP"
*/

#include <sys/types.h>
#include <sys/time.h>
#include <stdio.h>

/* programul */
main (int argc, char *argv[])
{
  struct timeval timeout;

  /* exista argumentele? */
  if (argc != 3)
    {
      printf ("Sintaxa: %s <#secunde> <#microsecunde>\n", argv[0]);
      return 1;
    }

  /* setam valorile */
  timeout.tv_sec = atol (argv[1]);
  timeout.tv_usec = atol (argv[2]);

  /* apelam select() pentru temporizare */
  if (select (0, NULL, NULL, NULL, &timeout) < 0)
    {
      perror ("Eroare la select().\n");
      return 2;
    }

  return 0;
}

