Új hozzászólás Aktív témák

  • emitter

    őstag

    válasz Jester01 #1318 üzenetére

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

    int
    input_timeout (int filedes, unsigned int seconds)
    {
    fd_set set;
    struct timeval timeout;

    /* Initialize the file descriptor set. */
    FD_ZERO (&set);
    FD_SET (filedes, &set);

    /* Initialize the timeout data structure. */
    timeout.tv_sec = seconds;
    timeout.tv_usec = 0;
    /*
    // select returns 0 if timeout, 1 if input available, -1 if error.
    return TEMP_FAILURE_RETRY (select (FD_SETSIZE,
    &set, NULL, NULL,
    &timeout));
    */
    }

    int
    main (void)
    {
    fprintf (stderr, ''select returned %d.\n'',
    input_timeout (STDIN_FILENO, 9));
    return 0;
    }


    pedig 5-öt ír ki, illetve azt amit megadok neki az input_timeout-nál :U
    azt mondtad h szedjem ki a temp_failure-t, hát kiszedtem, de így meg a select ha jól látom, nem is hívódik meg sehol...
    a timeout-ot még mindig nem értem: ez a kód hol számol vissza, mettől, és egyáltalán miért jó nekem ha visszaszámol? Vagy hogyan értelmezzem ezt a timeout-dolgot :F

Új hozzászólás Aktív témák