[SOLVED] Raspberry QTcpServer says "connection refused" to Windows Desktop QTcpSocket



  • Hi ! and here goes first post.

    As the title, says I am looking for a little experience with my QT Raspberry/Windows socket handshake.

    It works when server and client are on local machine
    Ports are forwarded appropriately
    IP address is correct.
    I can connect with telnet. ( can not open a connection )
    I have a native c++ example program that DOES work.

    EDIT-
    iptables are empty
    firewall and antivirus is off.

    SERVER CODE
    @
    m_server = new QTcpServer(this);

    // signal newConnection is auto-gened
    connect(m_server, SIGNAL(newConnection()), this, SLOT(ConnectionProcessMess$
    if(!m_server->listen(QHostAddress("127.0.0.1"), 51717))                    $
    {
        qDebug() << "Server could not start";
    }else{
        qDebug() << "Starting Server : " << getTime() << " Waiting for Msg : "<$
    }
    

    }

    /*

    • We have a request coming in.
      */
      void MyTcpServer::ConnectionProcessMessage()
      {
      qDebug()<<"Message in";
      }
      @

    CLIENT CODE
    @
    m_currSocket->connectToHost("192.168.1.109", 51717);
    if(!m_currSocket->waitForConnected(120000)) // we need to wait...
    {
    qDebug() << "Error: " << m_currSocket->errorString();
    }
    }
    @

    LISTEN STUFF
    @open ports and established tcp connections
    Active Internet connections (servers and established)
    Proto Recv-Q Send-Q Local Address Foreign Address State
    tcp 0 0 127.0.0.1:51717 0.0.0.0:* LISTEN
    tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN
    tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN
    tcp 0 0 0.0.0.0:54392 0.0.0.0:* LISTEN
    tcp 0 0 127.0.0.1:6010 0.0.0.0:* LISTEN
    tcp 0 0 127.0.0.1:6011 0.0.0.0:* LISTEN
    tcp 0 832 192.168.1.109:22 192.168.1.117:58142 ESTABLISHED
    tcp 0 0 192.168.1.109:38262 192.168.1.105:445 ESTABLISHED
    tcp 0 0 192.168.1.109:22 192.168.1.117:56924 ESTABLISHED

    programs with 51717 open
    (Not all processes could be identified, non-owned process info
    will not be shown, you would have to be root to see it all.)
    tcp 0 0 localhost:51717 : LISTEN @



  • I fixed this by setting the ip address to 0.

    @
    if(!m_server->listen(QHostAddress("0.0.0.0"), 51717)) $
    {
    qDebug() << "Server could not start";
    }else{
    qDebug() << "Starting Server : " << getTime() << " Waiting for Msg : "<$
    }
    @



  • Your server was initially only listening to connections on the same machine. If you want the server to listen to all network interfaces use:

    QHostAddress::Any


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.