<div dir="ltr">Another round of late late night hacking.<div><br></div><div>I've been further experimenting with ranch to implement a proper Telnet implementation (for those who thought Telnet was simply a TCP connection from A to B...nope..)</div><div><br></div><div>First, I wanted to compliment the softwre engineers who worked on gen_statem, it's a fantastic replacement for gen_fsm which consolidates a lot of previously seperate functions into something that is simpler to implement, but has a lot more functionality.</div><div><br></div><div>As part of the Telnet negotiation process, I am having to send a string of IAC codes to specify no echo, character mode, etc. to get the terminal characteristics that I want:</div><div><br></div><div><div><font face="monospace">negotiation(internal, preamble, #data{transport=Transport,socket=Socket}=Data) -></font></div><div><font face="monospace">    io:format("Sending preamble~n"),</font></div><div><font face="monospace">    Transport:send(Socket,<<255,253,1,255,253,31,255,251,1,255,251,3>>),</font></div><div><font face="monospace">    {next_state, negotiation, Data};</font></div></div><div><font face="monospace"><br></font></div><div>but now that I am sending this data, I am getting the terminal characteristics that I want, but as part of the negotiation, the client not only acknowledges the attributes that I wanted, but the client responds with attributes of its own:</div><div><br></div><div><div><font face="monospace">1> EventType info -- Msg {tcp,#Port<0.638>,</font></div><div><font face="monospace">                           <<255,252,1,255,251,31,255,250,31,0,170,0,113,255,</font></div><div><font face="monospace">                             240,255,253,1,255,253,3>>} -- Data {data,</font></div><div><font face="monospace">                                                                 nakbbs_telnet_ascii,</font></div><div><font face="monospace">                                                                 #Port<0.638>,</font></div><div><font face="monospace">                                                                 ranch_tcp} --</font></div></div><div><br></div><div><br></div><div>I know how to parse each of these bits, but am wondering how best to do the appropriate pattern matching to deal with each incoming bit of info.</div><div><br></div><div>The one saving grace is that each piece of the reply is dileniated with 255 followed by the protocol option to change (1 = echo, 31 = window size, etc.) <br></div><div><br></div><div>Is the correct approach to snip off each dileniated piece from the binary and match?</div><div><br></div><div>-Thom</div><div><br></div><div><br></div></div>