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. [SOLVED] Raspberry QTcpServer says "connection refused" to Windows Desktop QTcpSocket
Forum Updated to NodeBB v4.3 + New Features

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

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 17.2k 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.
  • R Offline
    R Offline
    Randman
    wrote on last edited by
    #1

    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 @

    1 Reply Last reply
    0
    • R Offline
      R Offline
      Randman
      wrote on last edited by
      #2

      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 : "<$
      }
      @

      1 Reply Last reply
      0
      • T Offline
        T Offline
        t3685
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0

        • Login

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