Results 1 to 3 of 3

Thread: Send TCP message

  1. #1
    Join Date
    Jan 2006
    Location
    Sta. Eugènia de Berga (Vic - Barcelona - Spain)
    Posts
    869
    Thanks
    70
    Thanked 59 Times in 57 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Send TCP message

    Hi,

    I'm trying to send a message through a TCP socket. The message contains numbers:

    Qt Code:
    1. char* pacDades = new char[50];
    2. int iLong = 25;
    3. pacData[0] = (char)iLong;
    4. pacData[1] = '$';
    5. pacData[2] = '0';
    6. pacData[3] = '$';
    7. quint16 qNum = 150;
    8. quint8 qNumFotosMSB = (qNum >> 8);
    9. qNumMSB += 48;
    10. quint8 qNumFotosLSB = qNum;
    11. qNumLSB += 48;
    12. pacData[4] = (char)qNumMSB;
    13. pacData[5] = (char)qNumLSB;
    14.  
    15. qint64 qNumBytes = m_qSocket.write(pacData,qLong);
    To copy to clipboard, switch view to plain text mode 

    When I recive the data,
    Qt Code:
    1. qNumImatgesLSB = qTextos.at(1).at(1).toAscii();
    To copy to clipboard, switch view to plain text mode 

    "qNumImatgesLSB" is -58 instead of 150.

    What I'm doing wrong?

    Thanks,
    Òscar Llarch i Galán

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Send TPC message

    What's the difference between qNumLSB and qNumFotosLSB?

  3. #3
    Join Date
    Jan 2006
    Location
    Sta. Eugènia de Berga (Vic - Barcelona - Spain)
    Posts
    869
    Thanks
    70
    Thanked 59 Times in 57 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Send TCP message

    Hi,

    Sorry, I have not changed all the variable names:
    qNumFotosMSB is qNumMSB
    qNumFotosLSB is qNumLSB

    I have solved this. The problem was on the variable definition on the reciver. I was using a qint16 instead of quin8.
    Òscar Llarch i Galán

Similar Threads

  1. statusBar() message color change
    By mclark in forum Qt Programming
    Replies: 2
    Last Post: 7th August 2007, 23:20
  2. Send a key to process
    By Nyphel in forum Qt Programming
    Replies: 2
    Last Post: 9th July 2007, 17:37
  3. How to send message to Desktop Widget
    By shyam prasad in forum Qt Programming
    Replies: 18
    Last Post: 18th April 2007, 11:00
  4. Message on close(x) button of Form
    By vishal.chauhan in forum Qt Programming
    Replies: 3
    Last Post: 29th January 2007, 09:39
  5. Communication between QThread and Yes/No QMessageBox?
    By pmaktieh.sirhc in forum Qt Programming
    Replies: 11
    Last Post: 25th January 2007, 03:45

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.