• Please review our updated Terms and Rules here

Next new application: Telnet?

Good idea .. I have FTP available because it's my domain, but I don't have anonymous FTP setup yet. I'll work on that.
 
The latest and greatest code, including a much better readme can be found here:

http://brutman.com/mTCP/telnet_2009-11-30.zip

I'm going to hang back for a bit and see what people think of it before doing any more code. Give it a whirl, and if it is missing something or you'd like to see something changed please let me know.


Mike
 
Hi Mike,

Can you perhaps explain how you handled both keyboard input and network input? In Unix we might use a single call to select but DOS has nothing like this. How does your event loop work? Does it constantly issue non-blocking polls?

Thanks,

Devin
 
Devin,

When I first started with the TCP/IP stack I tried making the data structures for the sockets look like their Unix counterparts. I quickly abandoned that and file descriptors because of the overhead.

The code to read a socket looks almost exactly like a send or receive call in Unix, but they are always non-blocking. Even in the case where data is available the caller is responsible for calling send/recv until they send all of the data they put in a buffer or receive enough data to move on. (Even on a Unix system it is possible for send or recv to process only part of your payload, thus forcing you to loop until everything you asked to send or receive is done.)

The keyboard input is non-blocking as well.

In general, the main loop of one of my mTCP programs is structured like this:

while ( !done ) {
Call the TCP library to see if any data has arrived at the Ethernet card
Check for open sockets that might have closed
Check open socket connections for received data and process it
Check the keyboard
}

The call to the TCP library is another polling operation. It checks for newly queued packets from the Ethernet packet driver, and then pushes them through the TCP stack. This makes incoming data available at the specific receive buffer for each socket before the user does a recv call to read it.

I thought about hooking the timer interrupt to do that processing automatically in the background, but it makes things slower because I would have to add more locks to ensure that two pieces of code weren't touching the same data structure at the same time.

In this scheme the programmer gets to control how aggressively the poll the adapter for data, but the programmer also is responsible for not forgetting to check for new data.

The telnet client is pretty simple. The telnet server I did for the telnet BBS earlier this year has to multiplex up to 10 different sockets, and maintain the state of 10 different client sessions. The polling overhead can get quite large there. I've thought about experimenting with a 'select' call that blocks until something actually happens as opposed to constantly polling all open file descriptors, but that is the only application with that problem so I've not implemented it yet.

Mike
 
PageUp and PageDown are not defined for a standard ANSI terminal. The arrow keys are. Home and Insert should work too, at least on a Linux machine - I don't think those are standard either.

The telnet portion is easy compared to the terminal emulation part .. Even for an 'ANSI' terminal the keys and strings are not well defined.

I'm glad it worked for you - what kind of machine is that?


Mike
 
Just a run of the mill 286, though my good monitor has unfortunately been buried and will remain inaccessible for a few months.
My only solution was a vga to tv adapter and the monitor from my Apple //c :)
 
I think that the Telnet client is probably good enough for now. That was a lot more work than I expected it to be because of the poor performance of the older video cards.

With what I have so far (Ping, DHCP, Telnet, FTP, IRC and Netcat) I'm getting pretty close to the full set of classic TCP/IP client apps. Does anybody have ideas for the next project?

Here is my partial list of other things to do:

  • A quick NTP client that I can use to set the time and date on my machines without clock cards.
  • Multi-session support for Telnet.
  • A fix to FTP to allow for spaces in filenames.
  • Wget

I'd also like to do a SMB client complete with the MSDOS device driver work to make a new drive letter, but that's going to be a significant challenge. Network redirectors weren't easy 20 years ago, and trying to find all of the tips I need to do it now would be very difficult.
 
Bare bones, perhaps. HTML and attachments would be a weak point ..
 
Thanks Mike!
Is Nov 30 2009 the latest version then? If so then I'll clean up my setup and make that the default.

Regarding e-mail client:
For bare bones Marc Ressl's NetMail is an under 70k executable and does SMTP and POP3 without a glitch. I've used it for years. To me, that and a lister is all you need. I used to just split off the attachments and process them separately (UUDECODE etc), but some aren't going to be functional in DOS.
 
There was a small fix that added another ANSI command. It helped 'TheKeep' telnet BBS figure out that the machine had ANSI support. That version is 12-12 and it is posted here: http://brutman.com/mTCP/

If there is good code out there already I'm not going to reinvent the wheel. I might check out NetMail for my own use instead of starting from scratch.

I also can go back to the telnet BBS project and start working on that again, although that's going to take a lot of work yet. It's barely functional and it will take a lot to draw people to a telnet BBS.
 
I've posted a new version (2009-12-27) at the same place. Here is the direct link: http://www.brutman.com/mTCP/telnet_2009-12-27.zip

Changes are:

  • Fix display handling bug for Monochrome Display Adapter (MDA) users that was causing freezing
  • Fix underlining for MDA users. (It wasn't underlining at all)
  • Fix [Enter] key processing. Enter will send CR/LF, while Ctrl-M will just send CR and Ctrl-J will just send LF. (Ctrl-Enter will also send LF.)
  • Add a toggle for local echoing. I hate local echoing because it is imprecise, but sometimes you need it.
  • Remove 'notelnetopts' and replace with a 'sessiontype' option that forces telnet option negotiation on or off entirely. This behaves more like Putty, which is a good thing.
  • Automatically turn telnet option negotation off if you are not connecting to the standard telnet port. (You can use the new sessiontype option if you need to force it on.)
  • Make the help screen a little prettier, including highlighting the command keys and the current state of the options.

And here is a current screen shot of it running in DOSBox:

telnet_2009-12-27_screenshot.gif



Enjoy!
 
And just for grins, here it is running in 80x50 mode connected to the welcome screen of 'TheKeep' BBS:

telnet_2009-12-27_screenshot_2.gif
 
Back
Top