Thread: select() ignoring timeval argument

  1. #1
    Registered User
    Join Date
    Dec 2008

    select() ignoring timeval argument

    I am new to this thread.

    I am using select() in my code.

    my code snippet:
    twait.tv_sec = 0;
    twait.tv_usec = THIRTY_MILLISECONDS;

    pollfds2_count = select (0, readfds, writefds,exceptfds, &twait);
    From one of the support forums i came to know that select() will return immediately even timeval parameter set to "non zero" or non NULL values. Am i correct? (They mentioned a possible bug in windows).

    For our application to work correctly select should wait for THIRTY_MILLISECONDS.

    How can i ensure that?

    How sleep will help?

    Please help me.


  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    What have you written into your fds members?
    Are you sure there really is nothing ready?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Portland, OR
    Passing 0 as the first argument to select() is certainly wrong as well. You need to pass it the actual number of fds you are watching (the maximum of the three sets)
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  2. brace-enclosed error
    By jdc18 in forum C++ Programming
    Replies: 53
    Last Post: 05-03-2007, 05:49 PM
  3. Directional Keys - Useing in Console
    By RoD in forum C++ Programming
    Replies: 38
    Last Post: 10-06-2002, 04:42 PM
  4. FAQ: Directional Keys - Useing in Console
    By RoD in forum FAQ Board
    Replies: 38
    Last Post: 10-06-2002, 04:42 PM