Nonblocking IO for stdin?

dhasenan dhasenan at gmail.com
Mon Jan 8 13:36:32 PST 2007


Hey all--

I'm trying to write a console telnet client. It works fine, except I can't get
keyboard input; or if I do, that blocks reading until the user presses a key.
(Actually until the user enters a carriage return; I'm on a line-buffered
console.)

- din.available() always returns 0, so I can't check that before each input.
- using din.getc() and watching for a newline doesn't work, since the terminal
doesn't send a continuous stream of newlines when there's no other input
- using din.eof() only tells me whether the user inputted an EOF character

I could do with sockets, if I knew how to open stdin as a socket.

So, how do I open stdin as a socket, or how else can I get nonblocking input
on stdin?

Thanks!

-dhasenan



More information about the Digitalmars-d mailing list