Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Qt tcp/ip server (sort of) works with raw telnet, but not python, netcat or PuTTy w/telnet
Forum Updated to NodeBB v4.3 + New Features

Qt tcp/ip server (sort of) works with raw telnet, but not python, netcat or PuTTy w/telnet

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 2.5k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    Vix_
    wrote on 18 Jun 2013, 00:00 last edited by
    #1

    I have a Qt tcp/ip server listening on a port. I can talk to it with telnet, but when I try with netcat the input commands are truncated. When I try to send it a command through python, it doesn't see anything. The strangest behaviour is with PuTTY (see below). Has anyone else run into an issue like this with a Qt tcp server? Code follows.

    Server

    @QTcpServer remoteControlServer;

    remoteControlClient = remoteControlServer.nextPendingConnection();

    connect(remoteControlClient, SIGNAL(readyRead()), this, SLOT(remoteCommandRead()));@

    The command interpreter -> If it's not the setup or configuration of the server, this is where I suspect the problem is. Is canReadLine() not doing what I want? I am just sending strings, so the line-oriented protocol is what I think I should be using. I do not undersand why, but if I chop two bytes off of the string, telnet works. The last two bytes are \r\n. Shouldn't simplified() remove those? If simplified doesn't work on a QByteArray why does this compile without errors in Qt Creator?

    @ void MainWindow::remoteCommandRead()
    {
    QByteArray lineBuffer;
    QByteArray consoleString;
    QByteArray command;
    QList<QByteArray> commandList;

    while(remoteControlClient->canReadLine())
        {
            lineBuffer = remoteControlClient->readLine();
            lineBuffer.chop(2);
            lineBuffer.simplified();
    
            commandList = lineBuffer.split(' ');@
    

    The python client

    @import socket
    remote_sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    server_address = ('address', port)
    remote_sock.connect(server_address)
    remote_sock.sendall('commandString')@

    Using telnet trhough PuTTy I discovered that there is some junk hanging around somewhere which I need to flush, but I don't know how much there is, where it is coming from or how to filter it out. When I enter a command using PuTTy the first time, the Qtserver side replies
    Unknown: ���� ����'������connect.
    The next time it gets Unknown: ���� ����'��'connect'
    Then Unknown: ��$connect
    And eventually it works and accepts the command Command: connect

    Any ideas about what is going on here?

    Many Thanks.

    1 Reply Last reply
    0

    1/1

    18 Jun 2013, 00:00

    • Login

    • Login or register to search.
    1 out of 1
    • First post
      1/1
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved