Re: Is there a getch()?

From: Jeremy Elson (jelson@blaze.cs.jhu.edu)
Date: 02/07/96


> > This is more of a general c question I think.  I want someone to be able 
> > to type in a letter and have my code react immediately (not after they 
> > press enter).  All of the ansi c books I have say to use getch().  I 
> > don't have getch().  It is supposed to be in stdio.h or conio.h.  I don't 
> > have a conio.h and it isn't in stdio.h.  I am running linux(bunch of 
> > different versions) with gnu c 2.6.3.  Is there another name for getch()?
> 
> The character-grabber in C I'm familiar with is getc(), but it polls 
> standard input, not a socket.
> 
> If you look deep into the socket-handling routines in circle, you may 
> find an input buffer.  If you can find this (I'm not sure if it exists in 
> circle, I'm just guessing it works this way), and learn how it works, you 
> can check the buffer before it gets passed to the command interpreter, 
> and just check for the oldest character (the one that was entered first 
> since the last buffer purge).

getc() and getch() should be in most standard C implementations; the problem
is not finding the right function but the fact that telnet clients are
usually in line mode when they connect to Circle (i.e. the 'telnet' program
only sends a complete line to Circle after the carriage-return, so getc()
and getch() will be useless).

You could tell 'telnet' to go to character mode if you really wanted to,
but I *strongly* recommend not doing that because it will drastically
increase the amount of network traffic.



This archive was generated by hypermail 2b30 : 12/07/00 PST