Results 1 to 7 of 7

Thread: QNativeSocketEngine

  1. #1
    Join Date
    Aug 2008
    Posts
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QNativeSocketEngine

    Hi I am encountering a problem with my program when it try to connect to another machine using QTCPSocket. I keep getting the message QNativeSocketEngine::write() was not called in QAbstractSocket::ConnectState continuously at a very fast interval.
    Below is some code I have to connect to a Server.

    Qt Code:
    1. tcpSocket1 = new QTcpSocket();
    2. tcpSocket1->connectToHost("192.168.0.101", 600, QIODevice::ReadWrite);
    3. .
    4. .
    5. .
    6. connect( tcpSocket, SIGNAL(readyRead()), this, SLOT(read_data()));
    7. connect( tcpSocket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(displayError(QAbstractSocket::SocketError)));
    To copy to clipboard, switch view to plain text mode 

    If there is anyone who can explain what is happening and what a solution is I would like to hear it.

    Thanks
    Last edited by jpn; 1st August 2008 at 21:25. Reason: missing [code] tags

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

    Default Re: QNativeSocketEngine

    Is there more code related to the socket? Especially one related to writing to it?

  3. #3
    Join Date
    Aug 2008
    Posts
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QNativeSocketEngine

    Qt Code:
    1. void Common::send_sock_data_1(int G_sock_data_len)
    2. {
    3. int byte_send;
    4. byte_send = tcpSocket->write(G_sock_data_1, G_sock_data_len);
    5. .
    6. .
    7. .
    To copy to clipboard, switch view to plain text mode 

    Here is my write function. I pass in an integer which represents the length of the message being sent. G_sock_data_1 is a char array. I would like to know what I am doing wrong, or if there is a better solution to write on a socket. Also I am porting code over from Windows to CentOS.
    Last edited by jpn; 5th August 2008 at 14:09. Reason: missing [code] tags

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

    Default Re: QNativeSocketEngine

    Did you wait for the socket to establish connection before writing the data to the socket?

  5. #5
    Join Date
    Aug 2008
    Posts
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QNativeSocketEngine

    I have been using the same socket for reading in data, and it works fine, but when I want to be able to write on the same socket I keep getting that "QNativeSocketEngine::write() was not called in QAbstractSocket::ConnectState" message over and over. When I run it under Windows it appears to work fine, but once I import to CentOS it doesn't work.

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

    Default Re: QNativeSocketEngine

    Could you prepare a minimal compilable example reproducing the problem?

  7. #7
    Join Date
    Oct 2008
    Posts
    1
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QNativeSocketEngine

    Just had this issue myself then eventually found out that the problem was that the server I was trying to connect to was down. Hadn't got as far as putting error checking in!

    Hopefully that helps anyone else who stumbles on this thread via google.

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.