Re: Telnet entry routines.

From: Trey T. Morita (tmorita@texas.net)
Date: 09/09/95


On Fri, 8 Sep 1995, Ron Poulton wrote:

> Perhaps people of specialized calibre will have begun to read this list 
> since my previous request for this information. <heh>.
> 
> I've been looking through the socket header files and the socket routines 
> within CircleMUD, and have made a few conclusions regarding the specific 
> operations of how CircleMUD telnets, however I am no closer (yet) to 
> knowing how to generate my own input routines.
> 
> It seems that CircleMUD receives user information via lines of data; the 
> user types in a line, which the client handles, then when RETURN is 
> pressed the client send that line of text which CircleMUD processes;
> 
> My interests are to find a method of control over the information typed 
> by the user in two instances:
> 
> 1) Ability to redisplay the line of text being entered without having the 
> user required to press Ctrl-R (or whatever other method is used).
> 
> 2) Capability of reading a single character from the telnet port.
> 
> Possibly after another month or so of digging I may discover more; I'm 
> curious if anyone has had luck in this endeavour and may share some 
> information with me that may increase my chance of success.
> 
> 
Hmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm.

If I understand it correctly, Circle 3.0 uses its own buffering routines for
input/output. Each descriptor has a buffer of type char of length 
MAX_INPUT/OUTPUT_LENGTH. There is a procedure called select, that "polls" 
all the descriptors for input pending/output pending. select can be both 
blocking and non-blocking, depending on what's in the time struct you 
send it. There are 3 calls to select in the "main game loop", and I as 
yet don't understand the 2nd one, but the others I understand. When 
select "polls" the descriptors, it sets a flag in the descriptor if that 
descriptor has input/output pending. Don't worry about the exception set.
If the descriptor has input pending, then process_input is called. I'm a 
bit shaky on this part, but here's what I think: the descriptor is a tcp 
type stream, sort of like a natural queue or buffer. process_input 
searches the stream for a newline, and if found, copies everything up to 
the newline into the descriptor buffer inbuf. I'm not real clear on 
whether telnet sends everything or just sends upon a newline. If it sends 
everything, then you can retrieve characters as the come in by playing 
with process_input.

Hmm, so for 1) hmm, I guess you could use process_input to scan the input 
stream for a control character, and if found, remove it and then send 
whatever you want to repeat to the output buffer. I guess.

And for 2) . . hmm, hmm. I'm not real sure about this, but if the socket 
were read using stdio functions, you could probably do it . . .

I don't think I've really answered either of your questions, but then 
they're not exactly phrased as questions, either. Here's my advice :
pick up a book on using C on the Unix system. Mine is called, 
coincidentally enough, "Using C on the UNIX System" by David A. Curry and is 
one of those O'Reilly & Associates Nutshell handbooks. I have 2 of these 
Nutshell books, this one and "Unix in a Nutshell", which tells you just about 
anything you could want to know about shells, scripts, filters, but is 
NOT a programming manual. I think Jeremy mentions a book in the 
commenting for comm.c somewhere, might try that one. Once you have a 
book, type in the examples, play with them, figure it out.

Trey



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