Results 1 to 3 of 3

Thread: Datatype transfer over qtcpsocket

  1. #1
    Join Date
    Jun 2016
    Posts
    2
    Qt products
    Qt5
    Platforms
    Windows

    Default Datatype transfer over qtcpsocket

    Hey guys, I'm taking my first few steps in qt.
    I've been trying to understand how to best approach data transfers between two machines and have found many answers about text and file transfers. But I'm still having trouble to understand the basic concept of datatypes and the translation into bytes.

    I understand the concept of tcp sockets and all that. I do have a client and a server console running and they communicate successfully. But what I'd like to do is send useful information for my application on each side.
    Let's say a command for the server to execute, like a function or querry, and then return a class instance, a table or anything else that the application on the other end can use and fill it's gui with. How would one approach such a translation into bytes, and then back into a useful format?

    Any info or hints are much appreciated

  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: Datatype transfer over qtcpsocket

    Complex communication needs two things
    - a protocol so each side knows what kind of data it should expect next, e.g. command, result, notification, etc
    - a format for serializing/deserializing data into/from a byte stream

    Each one can be handcrafted, e.g. using QDataStream and there are also solutions that combined them or some aspects of them, e.g. https://developers.google.com/protocol-buffers/ or https://google.github.io/flatbuffers/

    Cheers,
    _

  3. #3
    Join Date
    Jun 2016
    Posts
    2
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Datatype transfer over qtcpsocket

    Awesome! Dankeschoen!

    I'll try to learn and implement the protocol buffer compiler and API in my code.
    After knowing better what to look for, I also found these two simple videos explaining some basics. Hope it helps others as it did help me.

    C++ Qt 85 - Binary IO basic object serialization
    C++ Qt 86 - Advanced Binary IO

    Cheers

    Goran

Similar Threads

  1. Image transfer using QTcpsocket
    By anmol2701 in forum Qt Programming
    Replies: 4
    Last Post: 18th June 2015, 15:06
  2. QTcpSocket gzip and Transfer chunked
    By giusepped in forum Qt Programming
    Replies: 0
    Last Post: 10th August 2011, 16:41
  3. QTcpSocket problem in file transfer
    By omprakash in forum Qt Programming
    Replies: 6
    Last Post: 25th January 2010, 08:18
  4. File Transfer with QTcpServer and QTcpSocket
    By NoRulez in forum Qt Programming
    Replies: 2
    Last Post: 21st October 2009, 17:12
  5. QTcpSocket & transfer errors
    By jkam in forum Qt Programming
    Replies: 1
    Last Post: 20th July 2008, 20:42

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.