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. Send files over network

Send files over network

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 2.8k 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.
  • J Offline
    J Offline
    jere12
    wrote on last edited by
    #1

    Hello,
    I want to create a chat for exchanging text and files too (photos, videos ...). Thus, each participant sends each participant text and files.
    I do not know how to organize it.
    I think setting up a peer to peer architecture. I found a tutorial ("here":http://qt-project.org/doc/qt-5/qtnetwork-network-chat-example.html) to send text by peer to peer. However, I do not find how to send files.

    Does someone could help me achieve this?

    Thank you all.

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      QTcpSocket inhertits from QIODevice, which can send any type of binary data. That means you can use QDataStream.

      (Z(:^

      1 Reply Last reply
      0
      • J Offline
        J Offline
        jere12
        wrote on last edited by
        #3

        Ok, but in the tutorial, they use QUdpSocket instead of QTcpSocket. Can I use QDataStream with QUdpSocket ?
        In addition, do QDataStream allow me to send files and text or do I create 2 different sockets?
        If yes, I guess I just have to replace QString by QDataStream in the 'sendMessage' function, isn't it?

        1 Reply Last reply
        0
        • sierdzioS Offline
          sierdzioS Offline
          sierdzio
          Moderators
          wrote on last edited by
          #4

          Just check out the documentation, please. QUdpSocket and QTcpSocket both inherit from QAbstractSocket, which inherits from QIODevice.

          You can use the same socket to send and receive text and binary data. It is your responsibility, however, to properly parse the data at the receiving end.

          Also, please remember that UDP protocol is stateless and does not guarantee the order the packets come in. It also does not warn on transmission errors.

          (Z(:^

          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