select() ignoring timeval argument

This is a discussion on select() ignoring timeval argument within the Windows Programming forums, part of the Platform Specific Boards category; I am new to this thread. I am using select() in my code. my code snippet: --------------------- twait.tv_sec = 0; ...

  1. #1
    Registered User
    Join Date
    Dec 2008
    Posts
    3

    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.

    Regards,
    Naga

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,439
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,235
    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)
    Code:
    //try
    //{
    	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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21