I believe QtTcpSocket is used in a manner similar to the following:
Code:
#include <QTcpSocket>
...
QTcpSocket* socket = new QTcpSocket;
QString serverAddr = "192.168.1.100";
quint16 serverPort = 12345;
socket->connectToHost(serverAddr, serverPort);
...
char* data = ...;
qint64 dataSize = ...;
qint64 bytesWritten = 0;
while (bytesWritten < dataSize)
{
qint64 written = socket->write(data + bytesWritten, dataSize - bytesWritten);
if (written == -1)
{
// error; decide if you want to break from the loop, or try again.
}
else
{
bytesWritten += written;
}
}
You can read more here about
QTcpSocket. This class is a sub-class of
QAbstractSocket, which in turn is a sub-class of
QIODevice.
The links are pertinent to Qt 4.7.1; if this is not the version of Qt you are using, then please accept my apologies.