Categories:
.NET (357)
C (330)
C++ (183)
CSS (84)
DBA (2)
General (7)
HTML (4)
Java (574)
JavaScript (106)
JSP (66)
Oracle (114)
Perl (46)
Perl (1)
PHP (1)
PL/SQL (1)
RSS (51)
Software QA (13)
SQL Server (1)
Windows (1)
XHTML (173)
Other Resources:
How can I find out if there are characters available for reading?
How can I find out if there are characters available for reading (and if so, how many)? Alternatively, how can I do a read that will not block if there are no characters available?
✍: Guest
These, too, are entirely operating-system-specific. Some versions of curses have a nodelay function. Depending on your system, you may also be able to use ``nonblocking I/O'', or a system call named select or poll, or the FIONREAD ioctl, or c_cc[VTIME], or kbhit, or rdchk, or the O_NDELAY option to open or fcntl. You can also try setting an alarm to cause a blocking read to time out after a certain interval (under Unix, look at alarm, signal, and maybe setitimer).
If what you're trying to do is read input from several sources without blocking, you will definitely want to use some kind of a ``select'' call, because a busy-wait, polling loop is terribly inefficient on a multitasking system.
2015-04-29, 1083👍, 0💬
Popular Posts:
What are shared (VB.NET)/Static(C#) variables? Static/Shared classes are used when a class provides ...
What does static variable mean? There are 3 main uses for static variables: If you declare within a ...
How To Increment Dates by 1? - MySQL FAQs - Introduction to SQL Date and Time Handling If you have a...
What is the difference between "calloc(...)" and "malloc(...)"? 1. calloc(...) allocates a block of ...
What is the version information in XML? “version” tag shows which version of XML is used.