Results 1 to 2 of 2

Thread: sending Text or binary file over network

  1. #1
    Join Date
    Mar 2008
    Posts
    52
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default sending Text or binary file over network

    hi

    how can i send text string or a block of binary numbers over a LAN to another computer so that i can receive it there and display the data i send. I tried QSocket but it din't work. Here is the Code :

    Qt Code:
    1. void transmitter::dothis()
    2. {
    3. QVector<QRadioButton*> rButtonContainer;
    4. rButtonContainer.push_back(radioButton_1);
    5. rButtonContainer.push_back(radioButton_2);
    6. rButtonContainer.push_back(radioButton_3);
    7. rButtonContainer.push_back(radioButton_4);
    8. rButtonContainer.push_back(radioButton_5);
    9. rButtonContainer.push_back(radioButton_6);
    10.  
    11. QString str;
    12. for(int i=0; i <rButtonContainer.size(); ++i)
    13. {
    14. if(rButtonContainer[i]->isChecked())
    15. {
    16. str+=rButtonContainer[i]->text();
    17. }
    18.  
    19. QByteArray block = "";
    20. block.append(inputLine->text() );
    21. socket->write(block);
    22. }
    23. }
    To copy to clipboard, switch view to plain text mode 
    I have to send the Label of the RadioButton which is checked over the Network to another computer. Which i am not able to. ?? !!

    What is the code the receive slot should have to receive and display the data sent from the transmitter. ?? Pls get me out of this prob.

    Thank you
    Last edited by jpn; 20th March 2008 at 13:23. Reason: missing [code] tags

  2. #2
    Join Date
    Feb 2008
    Posts
    153
    Thanks
    40
    Thanked 8 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: sending Text or binary file over network

    There is already an example of this in the Qt4 documentation. Also, QTCPSocket is used in place of QSocket in qt4.

    Have a look here: http://doc.trolltech.com/latest/qtcpsocket.html

    There are some examples like the Fortune Client. Just modify some parts of it to make them work with your situation.

Similar Threads

  1. Unhandled exception in qatomic
    By NewGuy in forum Qt Programming
    Replies: 14
    Last Post: 23rd July 2013, 10:49
  2. qt-3.3.8 fail in scratchbox
    By nass in forum Installation and Deployment
    Replies: 0
    Last Post: 25th May 2007, 16:21
  3. Sending Binary File with QFTP
    By nbkhwjm in forum Newbie
    Replies: 2
    Last Post: 7th March 2007, 19:10
  4. qt network performance
    By criss in forum Qt Programming
    Replies: 16
    Last Post: 24th July 2006, 10:23

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.