Results 1 to 18 of 18

Thread: QTcpSocket connection problem

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    valdemar593 Guest

    Post Re: QTcpSocket connection problem

    gdb

    text Code:
    1. #0 0x00402b73 in QMetaObject::invokeMethod (obj=0x7e9ff4,
    2. member=0x22a33f "connectToHostImplementation", type=Qt::DirectConnection,
    3. ret=..., val0=..., val1=..., val2=..., val3=..., val4=..., val5=..., val6=...,
    4. val7=..., val8=..., val9=...)
    5. at /var/tmp/qt-src/src/corelib/kernel/qmetaobject.cpp:1135
    6. #1 0x001efe73 in invokeMethod (this=0x7e9ff4, hostName=..., port=6178, openMode=...)
    7. at ../../include/QtCore/../../src/corelib/kernel/qobjectdefs.h:408
    8. #2 QAbstractSocket::connectToHost (this=0x7e9ff4, hostName=..., port=6178,
    9. openMode=...) at /var/tmp/qt-src/src/network/socket/qabstractsocket.cpp:1304
    10. #3 0x001f1835 in QAbstractSocket::connectToHost (this=0x7e9ff4, address=...,
    11. port=6178, openMode=...)
    12. at /var/tmp/qt-src/src/network/socket/qabstractsocket.cpp:1417
    13. #4 0x080494e4 in Client::establishConnection (this=0xbffff1fc)
    14. at ../NetTestClient/client.cpp:13
    15. #5 0x08049201 in main (argc=1, argv=0xbffff2d4) at ../NetTestClient/main.cpp:8
    To copy to clipboard, switch view to plain text mode 

    qt creator

    0 QHashData::detach_helper2 qhash.cpp 206 0x001a18fa
    1 QHash<QObject*, QHash<QEvent::Type, int> >::detach_helper qhash.h 582 0x002e69eb
    2 detach qhash.h 299 0x002dbc23
    3 operator[] qhash.h 737 0x002dbc23
    4 QStateMachinePrivate::registerEventTransition qstatemachine.cpp 1598 0x002dbc23
    5 invokeMethod qobjectdefs.h 408 0x00a25e73
    6 QAbstractSocket::connectToHost qabstractsocket.cpp 1304 0x00a25e73
    7 QAbstractSocket::connectToHost qabstractsocket.cpp 1417 0x00a27835
    8 Client::establishConnection client.cpp 13 0x080494e4
    9 main main.cpp 8 0x08049201

    Last edited by wysota; 27th May 2011 at 17:12.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QTcpSocket connection problem

    What does the main() function look like?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    valdemar593 Guest

    Default Re: QTcpSocket connection problem

    Qt Code:
    1. int main(int argc, char *argv[])
    2. {
    3. QCoreApplication a(argc, argv);
    4. Client client;
    5. client.establishConnection();
    6. return a.exec();
    7. }
    To copy to clipboard, switch view to plain text mode 

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QTcpSocket connection problem

    Ah.... I missed it. You are creating a local variable called "clientSocket" in your constructor that shadows the class member called "clientSocket" thus it remains uninitialized and a dangling pointer causes a crash.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    valdemar593 Guest

    Default Re: QTcpSocket connection problem

    Oh my god =))
    Thanks a lot man!
    But what about the first example? Everything seems to be correct there, but the socket stays in connecting state all the time while the server emits newConnection()?

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QTcpSocket connection problem

    I don't know, I'd need to see code that's more complete than this.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Problem with connection
    By Adonitos in forum Qt Programming
    Replies: 4
    Last Post: 8th April 2011, 11:56
  2. Replies: 1
    Last Post: 15th November 2010, 11:36
  3. DB Connection Problem
    By ktmdwn in forum Qt Programming
    Replies: 13
    Last Post: 4th August 2010, 15:12
  4. SQL Connection Problem
    By Utku in forum Installation and Deployment
    Replies: 3
    Last Post: 25th October 2009, 13:21
  5. QTcpsocket - connection problem
    By vishesh in forum Qt Programming
    Replies: 1
    Last Post: 16th October 2007, 17:03

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.