Giter Site home page Giter Site logo

readline about qtelnet HOT 1 OPEN

silderan avatar silderan commented on July 19, 2024
readline

from qtelnet.

Comments (1)

silderan avatar silderan commented on July 19, 2024

Hi.

readyRead function is not the apropiate signal to connect to. Data comming from telnet server needs to be parsed/processed because it could come with telnet specific bye codes such as screen resize information or scape bytes.

So, you need to connect to newData signal where telnet protocol bytes are stripped out.

Furthermore than that, parameters from newData need to be adapted properly for stream classes (as readLine belongs to that kind of classes, isnt' it?)
That's because QTexStream spects zero terminated char array in constructor parameter.
And, remember that you are not sure if the char * that are you passing to the QTexStream constructor is a "correct" and "parseable" text. Starting that it's not a zero-terminated string, the array could contain unfinished Unicode characters. That means, that you can receive a newData call with just 1 byte of the two bytes of one unicode character. Without going so long, new line could be double byte: \n\r or \r\n.
So, you need to "clean up" incomming data before pass it to high-level class such as QTextStream.

Yeah, QTexStream could seem to you that it is a low-level class. But remember that networking is much more low-level :) It's a "layer" below.

The procedure to parse incoming data, at ANY layer is the same:

  1. Buffer it (static storage because it must persist between asyncronous calls)
  2. Parse buffered data looking for a REAL error or USABLE data. If no enough data to do this, return and wait for new data.
  3. Pass this data to a upper layer.
  4. Discard JUST data processed
  5. Go to step 2.

from qtelnet.

Related Issues (2)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.