select() from sockets & STDIN with ncurses

select() from sockets & STDIN with ncurses

Post by Jacob Shapir » Fri, 26 Apr 2002 20:37:41



Hello all,
I've been having this problem for a while.
I wrote a nifty UI with ncurses, and then
when I wanted to move one stage ahead,
that is, add some functionality to my UI with
sockets, I discovered that unless I want my
program to hog all the CPU, I'm gonna have
to make it select() from both the sockets and
STDIN.
The problem is, that I'm using ncurses.
For some reason, the program would not return
from select() when there is data on the sockets
unless I press some characters.
I've tried anything, from setting either the sockets
or STDIN to non-blocking.
For setting the buffer of STDIN to 0, or whatever.
(fcntl(), setbuf() and various ncurses specific functions)
My question is: Is there some kind of trick for doing it?
Is there a tutorial?
Is there anyone out there willing to look at my source?:)
Email me at jacob at logicolor.net if you're interested.
Thanks alot,
Jacob Shapiro.