Relative Content

Tag Archive for c++qtnetworking

Exe File Transfer – Formatting Issue

Okay, I’m working on a C++ program for my job as a little side project. I have the need to transfer an exe file over a network connection. I am using the Qt GUI library, which includes some handy socket classes. Rather than use libcurl, or some other FTP method, I want to implement the file transfer over my own sockets using my own protocol. I have a small python daemon running on a remote machine that my client connects to over TCP; the daemon then reads 4K chunks of the exe and sends them down the pipe. In the same daemon script, I tried copying the byte data of the exe to the local machine, and it works fine. However, on my client, the byte data is formatted differently. I use the readall() method of the QTcpSocket class to read the TCP packets. When I qDebug() to the console, the data is as expected: ‘MZx90x00x03’ etc. However, when I write the received data to a file using the write() method, I get garbage values. I’ve tried formatting as hex, but that doesn’t give me the expected values either. This is my first time doing something like this, and I’m committed to this method mainly because I want to learn where I’m going wrong and sharpen my coding skills. I don’t understand why qDebug() gives me the correct values, but any other method does not. Can anyone help?