Results 1 to 3 of 3

Thread: QTcpSocket: crash on write

  1. #1

    Default QTcpSocket: crash on write

    Hi everybody,


    I'm sometimes experiencing crashes on this function: qint64 QIODevice::write ( const QByteArray & byteArray );

    I am just using QTcpSocket and I am also checking that the QTcpSocket instance has the connected status before writing.

    I am not calling the flush method.


    Edit:
    I'm using this socket in two threads, one receives data from a server, the other sends data to this server.

    Cheers!
    Last edited by valerianst; 16th May 2014 at 12:37.

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QTcpSocket: crash on write

    Quote Originally Posted by valerianst View Post
    I'm using this socket in two threads, one receives data from a server, the other sends data to this server.
    This is most likely the problem, just don' do that.

    Cheers,
    _

  3. #3

    Default Re: QTcpSocket: crash on write

    thanks for your suggestion.

    Are the write and QTcpSocket methods in general safe?


    Added after 6 minutes:


    Just answered by myself. QObject is not thread safe so I guess QTcpSocket isn't either.

    I would like to avoid using mutexes in this case but I guess I have to
    Last edited by valerianst; 16th May 2014 at 15:35.

Similar Threads

  1. QTcpSocket - write to socket from several threads
    By Einat in forum Qt Programming
    Replies: 3
    Last Post: 8th November 2013, 06:45
  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.