Stuart James

Telnet Server Fails

Discussion created by Stuart James on Jul 5, 2017

We have an application running on a FRDMK64F development card using MQX 4.2.0.

The application presents a webpage to display the status and operation of the device. In addition it also runs a Telnet server so that we can modify operating parameters on the fly.

 The Telnet interface worked well locally within the company network but always gave problems when a remote connection via the internet was attempted, very rarely getting past the welcome message before the connection froze.

  We have tracked the problem down to the _io_telnet_write function in the file telnetio.c of RTCS. This function is called indirectly by _io_doprint for every character that is to be sent to the client. The problem stems from the way _io_telnet_write writes characters to the client socket, it looks as though _io_telnet_write was designed to send a block of characters to the socket and to flush the stream on exit. By sending 1 character at a time to _io_telnet_write, each character occupies one complete frame/packet. Obviously this is very inefficient, 44 frames are required just for the copyright message.

  As a workaround we have modify _io_telnet_write to only flush the stream when a CR or LF is issued or if outputting RAW data.

 I hope this helps anyone with the same problem. Or if anyone knows of a different way around this I would appreciate you comments.

Outcomes