Determine 255 from Char Input - over telnet lazarus / 38-Networking and Web Programming ---------------------------------------------------------------------- nugax · 2022-03-07 16:05 I am trying to determine if I am getting byte 255 from telnet. I am using char reads. Is this code right? Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i     if (chInput <> chr(0)) then    begin      case (chInput) of        chr(byte(255)):        begin        write('255 sent');        if (cyberio.PipeReadByte() = 241) then        begin          chInput := chr(0);          cyberio.PipeReadByte();          cyberio.PipeReadByte();          cyberio.PipeReadByte();          cyberio.PipeReadByte();          cyberio.PipeReadByte();          cyberio.PipeReadByte();          cyberio.PipeReadByte();          cyberio.PipeReadByte();          cyberio.PipeReadByte();         end;         end; ---------------------------------------------------------------------- MarkMLl · 2022-03-07 18:22 You should be able to define Chr(255) as #255 or #$ff. Alternatively change the char to a byte/integer at the top of the case statement. MarkMLl ---------------------------------------------------------------------- nugax · 2022-03-08 15:53 The idea that a byte can be larger than 1 char makes this tough to understand. im workign with telnet connections and sometimes they send control bytes over the connection that I have to address in input. ---------------------------------------------------------------------- MarkMLl · 2022-03-08 16:01 Quote from: nugax on March 08, 2022, 04:53:15 pmThe idea that a byte can be larger than 1 char makes this tough to understand. im workign with telnet connections and sometimes they send control bytes over the connection that I have to address in input. A byte can't be larger than one char. A character- if you're handling UTF-8- can be larger than one byte, and I've had to handle that in the past with APL over Telnet. 255 is a "special" in the Telnet protocol, but it's just a byte like any other. MarkMLl ---------------------------------------------------------------------- nugax · 2022-03-08 19:13 Ah ok. A particular telnet client sends the NO OP and then will disconnect. its ftrustrating. Im not exactly sure how to handle the 255 byte it sends. It causes the connection to drop. I suppose I want to read in via byte not via character. Quote from: MarkMLl on March 08, 2022, 05:01:25 pmQuote from: nugax on March 08, 2022, 04:53:15 pmThe idea that a byte can be larger than 1 char makes this tough to understand. im workign with telnet connections and sometimes they send control bytes over the connection that I have to address in input. A byte can't be larger than one char. A character- if you're handling UTF-8- can be larger than one byte, and I've had to handle that in the past with APL over Telnet. 255 is a "special" in the Telnet protocol, but it's just a byte like any other. MarkMLl ---------------------------------------------------------------------- MarkMLl · 2022-03-08 20:17 Quote from: nugax on March 08, 2022, 08:13:48 pmAh ok. A particular telnet client sends the NO OP and then will disconnect. its ftrustrating. Im not exactly sure how to handle the 255 byte it sends. It causes the connection to drop. I suppose I want to read in via byte not via character. You DEFINITELY want to read bytes, since the Telnet protocol is at a lower level in the network stack than the presentation of locale- specific characters, and then have a state machine to track what's happening. In the past I've tweaked the version of lnet that's with FPC to handle some of the extra states coming from a mainframe emulator, but I really wouldn't recommend that you use that: while the Telnet stuff is fairly straightforward the underlying socket handling is anything but. I plan to reimplement Telnet for my own use at some point, with a background thread and state machine splitting out the data stream plus a separate FIFO for formatted control messages and their responses. MarkMLl