Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Writing QByteArray with QTcpSocket: null terminated?

Writing QByteArray with QTcpSocket: null terminated?

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 4.7k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Q Offline
    Q Offline
    qtradar
    wrote on last edited by
    #1

    Hi,

    probably an easy question for many here, but when I write a QByteArray to a QTcpSocket using the write(const QByteArray &) method, will the written data be null-terminated or not? From the documentation I see that QByteArray is implicitly null-terminated but I do not want the termination byte to go onto the network.

    My workaround would be to use QTcpSocket::write(QByteArray::constData(), QByteArray::size()) but perhaps there is an easier way to do it.

    Thanks.

    1 Reply Last reply
    0
    • O Offline
      O Offline
      ostash
      wrote on last edited by
      #2

      According to qiodevice.h:

      inline qint64 write(const QByteArray &data)
      { return write(data.constData(), data.size()); }

      1 Reply Last reply
      0
      • Q Offline
        Q Offline
        qtradar
        wrote on last edited by
        #3

        Ok, that's the same then, thanks.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved