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. Sockets joins contents!

Sockets joins contents!

Scheduled Pinned Locked Moved General and Desktop
3 Posts 3 Posters 764 Views 1 Watching
  • 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.
  • M Offline
    M Offline
    MohammadReza
    wrote on last edited by
    #1

    Hello friends.
    When I use two socket->write() immediately in the sender side, the receiver side receives mix of 2 content!
    For example

    In the sender side:
    @
    ...
    socket->write("sth1");
    socket->write("sth2");
    ...
    @

    In the receiver side I received "sth1sth1"!
    But I want to receives "sth1" & "sth2" separately.

    I need to this approach of sending contents.

    How can I do it?

    Tanks a lot.
    Ya Ali.

    1 Reply Last reply
    0
    • p3c0P Offline
      p3c0P Offline
      p3c0
      Moderators
      wrote on last edited by
      #2

      Hi,

      Try to "flush":http://qt-project.org/doc/qt-5/qabstractsocket.html#flush the buffered data after the first write.

      157

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi,

        Using write like this, you get the correct result. If you want to get "sth1" and "sth2" as two different things you need to separate them using e.g. \n

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        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