944,087 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 1039
  • C++ RSS
Nov 18th, 2007
0

How to transport a file with QTcpSock in LAN?

Expand Post »
Hello,everybody!

I'm writing a LAN communication programming,and I need to transport a file between different host computer.
I know that the TCP is a kind of stream-oriented connection.But look at the fallowing codes:
C++ Syntax (Toggle Plain Text)
  1. void TripPlanner::sendRequest()
  2. {
  3. QByteArray block;
  4. QDataStream out(&block, QIODevice::WriteOnly);
  5. out.setVersion(QDataStream::Qt_4_1);
  6. out << quint16(0) << quint8('S') << fromComboBox->currentText()
  7. << toComboBox->currentText() << dateEdit->date()
  8. << timeEdit->time();
  9. if (departureRadioButton->isChecked()) {
  10. out << quint8('D');
  11. } else {
  12. out << quint8('A');
  13. }
  14. out.device()->seek(0);
  15. out << quint16(block.size() - sizeof(quint16));
  16. tcpSocket.write(block);
  17. statusLabel->setText(tr("Sending request..."));
  18. }
I don't think it's a stream but a segment,do I?

And my other question is how to transport a file by TcpSocket.
I am Chinese,so the file may not be Enlish single,and the file may be alse a binary data file. How do I transport it?

I know that my English is poor,but I will try my best to exchange it!
Help me,please!
Thank anybody who look at this thread!

By the way, I had another question: what's the meaning of "hen & egg problem"(I'm not a English mother language men).
Last edited by cscgal; Nov 18th, 2007 at 4:34 pm. Reason: Added code tags
Similar Threads
Reputation Points: 10
Solved Threads: 0
Light Poster
meiyantao is offline Offline
31 posts
since May 2007
Nov 18th, 2007
0

Re: How to transport a file with QTcpSock in LAN?

chicken & egg proglem

If the file contains binary representation of integers then the bytes may have to be reversed on the receiving os. This is common problem when transferring files between MS-Windowos and *nix/Unix -- big endian little endian

As for your specific question -- I don't know, sorry.
Last edited by Ancient Dragon; Nov 18th, 2007 at 4:46 pm.
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2282
Retired and Enjoying Life
Ancient Dragon is offline Offline
21,957 posts
since Aug 2005
Nov 18th, 2007
0

Re: How to transport a file with QTcpSock in LAN?

chicken & egg proglem
Thanks! Maybe I could find it in google by myself first, I'm sorry for my lazy.

If the file contains binary representation of integers then the bytes may have to be reversed on the receiving os. This is common problem when transferring files between MS-Windowos and *nix/Unix -- big endian little endian
This is important for me. I guess that Qt may encapsulate it in an easy way.
As for your specific question -- I don't know, sorry.
You have help me so much!
Reputation Points: 10
Solved Threads: 0
Light Poster
meiyantao is offline Offline
31 posts
since May 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: Return function
Next Thread in C++ Forum Timeline: program with error





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC