My application basically is a CLI with all the expected features like prompt, history etc., it needs to wait on STDIN for user input. For this I am using readLine system cal
I am using readLine system call.
libreadline
You provide inconsistent information. What system would that be that has a system call readLine
?
If you use libreadline, you are rather calling library functions. But then, according to the GNU Readline Library Function and Variable Index, there is no function readLine
, there's only readline. With it you could use either the
Variable: rl_hook_func_t * rl_event_hook
If non-zero, this is the address of a function to call periodically when Readline is waiting for terminal input. By default, this will be called at most ten times a second if there is no keyboard input.
(you'd set it to a function where you poll your network socket and respond to messages)
or the
Alternate Interface
An alternate interface is available to plainreadline()
. Some applications need to interleave keyboard I/O with file, device, or window system I/O, typically by using a main loop toselect()
on various file descriptors. To accommodate this need, readline can also be invoked as a `callback' function from an event loop. There are functions available to make this easy.
There's an example program using the alternate interface: Alternate Interface Example.