Skip to main content
  1. Posts/

Day 70c - My Pencils are not Yet Sharp Enough

OldDays duka-verle

Limited progress.
Limited progress.

In which we start to dig in, but only make nominal progress.


Work on the New Server Code Every Seventh Day
#

The new server code will primarily be in Erlang, which may seem an odd choice but is really not. I want a distributed, highly scalable, robust system; and that’s what Erlang has been delivering for decades. And personally, I wanted to try out a nice functional language with a toolset completely foreign to me. I’m sure I’ll learn a lot, which may include this being a bad choice after all.

Eager to avoid blank page syndrome, I looked for a nice example to start with, hopefully something that would already accept multiple telnet connections. So I grabbed the chat server example from ErlangCentral and set about making it work.

It compiled and ran fine, or seemed to, but when I used Putty to connect to it my log filled with:

new connection from ÿûÿû ÿûÿû'ÿýÿûÿý
<ÿûÿû ÿûÿû'ÿýÿûÿý> ÿþ
<ÿûÿû ÿûÿû'ÿýÿûÿý> ÿþ  
<ÿûÿû ÿûÿû'ÿýÿûÿý> ÿþ

scrolling endlessly until I killed the Putty window.

On a whim, I tried telling Putty to use a Raw connection instead of Telnet:

Putty in Raw mode.
Putty in Raw mode.

…which gave me better results:

new connection from Sensible1
<Sensible1> This is a test
<Sensible1> Goodbye
lost connection from Sensible1

But why?

Failed Negotiations
#

Looking at the actual contents of the Telnet connection “username”:

[ list_to_integer(Hex, 16) ||
  Hex <- ["ff", "fb", "1f", "ff", "fb", "20", "ff", "fb", "18", "ff", "fb", "27", "ff", "fd", "01", "ff"] ] 
-> [255,251,31,255,251,32,255,251,24,255,251,39,255,253,1,255]
ok

and comparing it to a handy Telnet negotiation reference confirmed my suspicions. Putty was trying to negotiate various Telnet options, unprompted by the Erlang app.

Apparently Putty defaults to an “active” Telnet negotiation. Having discovered that, I knew which setting to tweak, and suddenly everything worked as expected.

Putty Telnet negotiation config.
Putty Telnet negotiation config.
new connection from PassiveTelnet
<PassiveTelnet> Hello there!
new connection from RawTCP
<RawTCP> Hello there!

Learning Experience
#

Getting this far took entirely too long, we aren’t passing any tests, and the question still remains whether I should write code for actual Telnet option negotiation. Looking forward to an actual feeling of accomplishment. Tomorrow.


Useful Stuff
#


More to come
More to come

Day 70c code - new server