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

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

    XMLWordPrintable

Details

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

    Description

      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
      

      Attachments

        Issue Links

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

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes