Thread: Convert Qt Tcp Server to boost

  1. #1
    Registered User
    Join Date
    Jun 2018
    Posts
    1

    Convert Qt Tcp Server to boost

    Hi All,

    New here, learning C++ Done a little bit of C# and Java before, but this application has to be in C++

    I found an application using the Qt framework for a TCP server, but since I have to dynamically link and include the frameworks/libraries, etc .. it seems to be a right mission, so I would like to convert it using boost.

    basically, what it does, it listens for connections, accepts a connection and creates a new object for each connection (client). The clients then send in a plain text string to subscribe to a certain "object/class".

    Anyway, in this class, there is a function that updates or gets call continuously (from another function) and if the new value is not equals the old value, it notifies the client (not all, but only the client(s) that subscribed)

    Qt code looks like this:

    Code:
    void DoubleDataRef::updateValue(double newValue) {
        if(_value != newValue) {
            _value = newValue;
            if(!_valueValid) setValueValid();
            emit changed(this);
        }
    }
    In Qt, the signal/slot connects the client to this class function and when "emit changed(this)" is called, it writes the new value to the client/socket (I assume).

    How would I be able to apply the same in boost ? I am just looking for someone to point me in the right direction ?

    Can I just call a function if the value above have changed (instead of emit), that fire an async_write (_value) to the client socket ? Do I have to pass a pointer to the client socket in order for this class to know which client socket to write to ?

    Thanks!

  2. #2
    Registered User
    Join Date
    Oct 2006
    Posts
    3,445
    emit is a keyword that the QMake program understands. the C++ compiler sees it as an empty #define macro. Behind the scenes, it's just calling changed(), so I think it's probably safe for you to do that when converting to boost.
    What can this strange device be?
    When I touch it, it gives forth a sound
    It's got wires that vibrate and give music
    What can this thing be that I found?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. http server using boost asio
    By EverydayDiesel in forum C++ Programming
    Replies: 6
    Last Post: 02-05-2018, 05:00 PM
  2. Boost.Asio: Which method of server coding is more robust?
    By Chris87 in forum C++ Programming
    Replies: 2
    Last Post: 10-29-2017, 03:30 AM
  3. Boost::asio unithread server-client problem.
    By Bruno Miguel in forum C++ Programming
    Replies: 0
    Last Post: 08-20-2016, 04:55 PM
  4. TCP Server on Linux + boost
    By kargo in forum C++ Programming
    Replies: 6
    Last Post: 06-10-2011, 06:38 PM
  5. Replies: 3
    Last Post: 10-15-2009, 08:58 AM

Tags for this Thread