Non- Blocking Input
Tom Boutell
boutell at freezer.it.udel.edu
Sat Nov 24 07:40:11 AEST 1990
Hi, folks. I'm the author of The Broken Throne, a multiplayer internet game.
My particular pain today is, I can't find a terribly portable way to check
for input from the user. I know it's not a fully portable thing in any
case, but is there a good source of multiple solutions for multiple machines
that I can incorporate into my code with a judicious bunch of #ifdefs?
For my own (SunOS) use, the code gets hold of the fd of stdin, then uses
ioctl(I_PEEK) on that to determine whether there's a key available. Works
like a charm but most folks can't do it. Is the nodelay() keyword available
under *other people's* versions of Curses the most portable method around?
One other question: usleep(xxx) sleeps for xxx microseconds under SunOS.
Is there a more portable equivalent? I need a good way of giving about a
tenth of a second back to the OS to avoid writing CPU- hungry code. (I'd
prefer to use input signals, but I keep running into situations where
I stop receiving signals because another came in as I handled the first.
Very frustrating business.)
--
THE TECHNOLOGY HOUSE: An idea whose time has come!
My girlfriend is a pseudo- aardvark. She is quite insistent on this point.
And remember- when all else fails- and no one else can help-
boutell at freezer.it.udel.edu
More information about the Comp.unix.questions
mailing list