Thread: Non Blocking I/O

  1. #1
    Registered User
    Join Date
    Mar 2002
    Posts
    15

    Non Blocking I/O

    I know I can use threads to perform operations like:

    Code:
    getline(cin, str)
    but I was wondering if there was another way. It just seems like there should be someway to check if the input buffer has data in it or not, I'm just not sure how.

    Thanks,

    PetrolMan

  2. #2
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,195
    check for WM_CHAR messages and process them if using windows. Otherwise you need to look up asynchronous keyboard states.

  3. #3
    Registered User
    Join Date
    Apr 2006
    Posts
    2,149
    Quote Originally Posted by PetrolMan View Post
    I know I can use threads to perform operations like:

    Code:
    getline(cin, str)
    but I was wondering if there was another way. It just seems like there should be someway to check if the input buffer has data in it or not, I'm just not sure how.

    Thanks,

    PetrolMan
    Do to the nature of standard input, there is no way to do this; standard input is defined to block.

    Such a thing would have to be done via some other input librairy, like as abachler suggests, the Windows native API.
    It is too clear and so it is hard to see.
    A dunce once searched for fire with a lighted lantern.
    Had he known what fire was,
    He could have cooked his rice much sooner.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Raw I/O vs. Stream I/O
    By NuNn in forum C Programming
    Replies: 1
    Last Post: 03-17-2009, 08:32 AM
  2. asynchronized I/O == multiplexing I/O?
    By George2 in forum C Programming
    Replies: 1
    Last Post: 07-24-2006, 10:06 AM
  3. why page based I/O can improve performance?
    By George2 in forum C Programming
    Replies: 1
    Last Post: 06-12-2006, 07:42 AM
  4. Overlapped I/O and Completion Port :: Winsock
    By kuphryn in forum Windows Programming
    Replies: 0
    Last Post: 10-30-2002, 05:14 PM
  5. WSAAsyncSelect I/O Mode :: Winsock
    By kuphryn in forum Windows Programming
    Replies: 1
    Last Post: 05-12-2002, 03:23 PM