Results 1 to 4 of 4

Thread: QTcpSocket question, write method

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Apr 2014
    Posts
    5
    Thanks
    5
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QTcpSocket question, write method

    ChrisW6
    Sorry for not posting a code before, it was a little bit complex. Anyway, your answer helped me. Here is something like the code i have now:
    Qt Code:
    1. clientConnectionSocket->waitForReadyRead();
    2. QByteArray data = clientConnectionSocket->readAll();
    3. clientConnectionSocket->write("some data");
    4. QTest::qWait(1000);
    To copy to clipboard, switch view to plain text mode 

    I added qWait to manually start event loop. Is it a bad solution?
    Last edited by Anslem; 19th May 2014 at 09:56.

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: QTcpSocket question, write method

    QTest is for testing so, yes, putting that in production code is not a good thing.
    Qt networking works best when used through it asynchronous (normal, non-blocking) interface.
    Qt network programming
    Network examples especially the non-blocking fortune client.

  3. The following user says thank you to ChrisW67 for this useful post:

    Anslem (1st June 2014)

Similar Threads

  1. QTcpSocket: crash on write
    By valerianst in forum Qt Programming
    Replies: 2
    Last Post: 16th May 2014, 15:28
  2. QTcpSocket write():: How many data sends?
    By Daxos in forum Qt Programming
    Replies: 3
    Last Post: 29th July 2010, 10:27
  3. QTcpSocket Write & \0 \x00
    By NewGuy5800 in forum Newbie
    Replies: 1
    Last Post: 25th April 2010, 10:23
  4. read and write on qtcpsocket
    By dognzhe in forum Qt Programming
    Replies: 1
    Last Post: 2nd June 2009, 09:42
  5. QTcpSocket waiting for write to be read
    By spraff in forum Qt Programming
    Replies: 1
    Last Post: 23rd December 2008, 19:12

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.