Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-28787

QTcpServer fails to start listening with Windows 7 + 8 & mingw

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: P1: Critical P1: Critical
    • 5.0.1
    • 5.0.0
    • Network: Sockets
    • None
    • Windows 7 + 8.0, Qt 5.0 release, Mingw
    • e3bd06426afce9773fa64afe1a9946647cdec181

      QTcpServer fails to start listening, reporting "Unknown error" (QAbstractSocket::UnknownSocketError).
      "::bind" call returns false.

      Simple program to illustrate (works with Qt 4.8.2)

      project file:

      QT       += core network
      
      TARGET = tcpserver
      CONFIG   += console
      CONFIG   -= app_bundle
      
      TEMPLATE = app
      
      
      SOURCES += main.cpp
      

      source file:

      #include <QCoreApplication>
      #include <QTcpServer>
      #include <QDebug>
      
      int main(int argc, char *argv[])
      {
      	QCoreApplication a(argc, argv);
      	QTcpServer srv;
      	bool r = srv.listen();
      	qDebug() << srv.errorString();
      	return r;
      }
      

      After rebuilding network module with debug enabled, I get the following output for the given example program:

      WSA error : WSAEFAULT
      more details (Система обнаружила недопустимый указатель адреса при попытке использовать в вызове аргумент указателя.)
      (unlocalize.com untranslates this message as
      The system detected an invalid pointer address in attempting to use a pointer argument in a call.)
      QNativeSocketEnginePrivate::nativeBind(0.0.0.0, 0) == false (Unknown error)

      If I specify address to listen explitily, or use QHostAddress::AnyIPv4 or QHostAddress::AnyIPv6 server starts:

      bool r = srv.listen(QHostAddress("127.0.0.1")); //ok
      bool r = srv.listen(QHostAddress::AnyIPv4); //ok
      bool r = srv.listen(QHostAddress::AnyIPv6);// ok
      bool r = srv.listeb(QHostAddress::Any); //not ok
      

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            shkearns Shane Kearns
            lol4t0 Ilya Sidorov
            Votes:
            1 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes