Results 1 to 7 of 7
Hi group,
I'm looking for a way to check if any data is waiting on stdin.
I know I can use Select under linux but that will not work with
...
- 09-27-2008 #1Just Joined!
- Join Date
- May 2005
- Posts
- 15
Checking stdin for new data
Hi group,
I'm looking for a way to check if any data is waiting on stdin.
I know I can use Select under linux but that will not work with
Windozes and I want to be able to use the same code for both.
I could use getc and then ungetc but that is sloppy.
Any ideas?
- 09-28-2008 #2
may we ask what language?
New to the internet, technical forums, or the hacker / open source community??
Read this to learn good posting habits http://www.catb.org/~esr/faqs/smart-questions.html
RHCE for RHEL version 5
RHCT for RHEL version 4
- 09-28-2008 #3Linux Newbie
- Join Date
- Jan 2008
- Location
- UK
- Posts
- 211
Hi,
How about setting up buffers and then you can read write manipulate them as you wish. Use a general buffer setup in C etc so that it is portable.
wowbag1
- 09-29-2008 #4Just Joined!
- Join Date
- May 2005
- Posts
- 15
- 09-29-2008 #5Just Joined!
- Join Date
- May 2005
- Posts
- 15
That is what I am doing but it gets a little messy. The problem is that I am waiting for input in subroutine and the input can be either a numerical string for the length of the data or the data itself. It work well but the caller may send more data then they sead they were. in this case I need to filter out the extra data, reading the steam until I get what looks like a valid length ( "nn\n") or a quit command ("q\n").
It would just be clearer to have a way of checking the input.
- 09-30-2008 #6
I know nothing about programming under Windows, but:
select Function (Windows)
select() is probably the best option for this if you can get it working, since it's explicit purpose is to tell you when a stream is ready.DISTRO=Arch
Registered Linux User #388732
- 10-02-2008 #7Just Joined!
- Join Date
- May 2005
- Posts
- 15


Reply With Quote
