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: QAbstractSocket::waitForBytesWritten() is not allowed in UnconnectedState
Forum Updated to NodeBB v4.3 + New Features

SOLVED: QAbstractSocket::waitForBytesWritten() is not allowed in UnconnectedState

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 7.3k 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.
  • J Offline
    J Offline
    johnmerlino
    wrote on last edited by
    #1

    I am getting the following error:

    QAbstractSocket::waitForBytesWritten() is not allowed in UnconnectedState

    Basically, I instantiate QUdpSocket and it seems to connect fine because on my log it says "Listening on port". And then when I run nestat on ubuntu it shows that port in use.

    @Gateway::Gateway(QObject *parent, qint16 port, bool load_mirrors)
    m_socket(new QUdpSocket(this)),
    m_database(new Database(this)),
    m_notify(new Notify(this))
    {

    connect(m_socket, SIGNAL(readyRead()),
    this, SLOT(readData()));

    if (m_socket->bind(m_port)) {
    Log::write(QString("Listening on port %1\n").arg(port), Log::LogAll);
    } else {
    Log::write(QString("Socket Bind Error: %1\n").arg(m_socket->errorString()), Log::LogAll);
    m_exit = true;
    return;
    }
    ...
    }

    void Gateway::readData()
    {
    while (m_socket->hasPendingDatagrams()) {
    QByteArray data;
    data.resize(m_socket->pendingDatagramSize());
    m_socket->readDatagram(data.data(), data.size(),
    &m_clientAddr, &m_clientPort);
    Log::write(QString("Data from socket: %1\n").arg(GprsMsg::toAsciiString(data)));
    handlePacket(data);
    }
    }@

    But it seems like that log "Data from socket: " in readData() is never reached. So I am not sure what the issue can be.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Might be stupid question but… Are you sending anything to that port ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • J Offline
        J Offline
        johnmerlino
        wrote on last edited by
        #3

        It was because the vpn was down

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Glad you found out !

          Can you please also update the thread title prepending [solved] so other forum users may know a solution has been found :)

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          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