#define TCP_MAXBUF 0x08000 // max TCP send and receive size buffer 32768 (MAX right now)
// Send File
do
{
// read file pattly
qint64 bytesRead = vrFile->read((char *)buffer,TCP_MAXBUF);
int sentSize = pFPSocket->write(fileBuffer.data(), bytesRead);
pFPSocket->flush();
if(!pFPSocket->waitForBytesWritten(Timeout))
{
theLog
->WriteLog
(QString("Wait for bytes written timed out"),LOG_LEVEL_ERR
);
}
}while(!vrFile->atEnd()) ;
//flush the file packet
pFPSocket->flush();
// Send Ack
outAck << (unsigned char)TCP_DISCONNECT;
outAck << (quint32)1;
outAck << (unsigned char)"¤";
int i = sizeof(TCPPacket);
if(pFPSocket->write(ackBuffer.data(),6) < 6 )
{
// ERROR not total ack sent
theLog
->WriteLog
(QString("Could not store %1, complete ack not sent.").
arg(Filename
),LOG_LEVEL_ERR
);
statusOK = false;
}
pFPSocket->flush();
if(!pFPSocket->waitForBytesWritten(Timeout))
{
// ERROR not total ack sent
theLog
->WriteLog
(QString("Could not store %1, ack bytes not written.").
arg(Filename
),LOG_LEVEL_ERR
);
statusOK = false;
}
#define TCP_MAXBUF 0x08000 // max TCP send and receive size buffer 32768 (MAX right now)
// Send File
do
{
// read file pattly
qint64 bytesRead = vrFile->read((char *)buffer,TCP_MAXBUF);
int sentSize = pFPSocket->write(fileBuffer.data(), bytesRead);
pFPSocket->flush();
if(!pFPSocket->waitForBytesWritten(Timeout))
{
theLog->WriteLog(QString("Wait for bytes written timed out"),LOG_LEVEL_ERR);
}
}while(!vrFile->atEnd()) ;
//flush the file packet
pFPSocket->flush();
// Send Ack
QByteArray ackBuffer(7, 0);
QDataStream outAck(&ackBuffer, QIODevice::WriteOnly);
outAck << (unsigned char)TCP_DISCONNECT;
outAck << (quint32)1;
outAck << (unsigned char)"¤";
int i = sizeof(TCPPacket);
if(pFPSocket->write(ackBuffer.data(),6) < 6 )
{
// ERROR not total ack sent
theLog->WriteLog(QString("Could not store %1, complete ack not sent.").arg(Filename),LOG_LEVEL_ERR);
statusOK = false;
}
pFPSocket->flush();
if(!pFPSocket->waitForBytesWritten(Timeout))
{
// ERROR not total ack sent
theLog->WriteLog(QString("Could not store %1, ack bytes not written.").arg(Filename),LOG_LEVEL_ERR);
statusOK = false;
}
To copy to clipboard, switch view to plain text mode
Bookmarks