Stopping data transfer with QTcpSocket
hi is it possible to stop the data transfer?
i tried with QTcpSocket::close() and QTcpSocket::abort()
but when i capture the transfer with wireshark the operating system sends the data furthermore
i dont know how to stop it
I am not a specialist on this topic but I would assume that you can not interrupt the ongoing sending of data and that the socket will abort or close as soon as the current operation has finished.
Have you tried using "abort":http://qt-project.org/doc/qt-4.8/qabstractsocket.html#abort ? According to Qt documentation it should fit your needs:
bq. Aborts the current connection and resets the socket. Unlike disconnectFromHost(), this function immediately closes the socket, discarding any pending data in the write buffer.
yes i used abort but windows sends the data furthermore
[quote author="sryyy" date="1334920309"]yes i used abort but windows sends the data furthermore[/quote]
Hm... could please "check this example app":http://qt-project.org/doc/qt-5.0/network-fortuneclient.html? It uses abort and might be useful to debug your issue.
this example sends only a little string
in my project i send a 9 mb file
like in the example i use QTcpSocket::abort() but
windows 7 sends the data till its complete transfered :/
ok i solved this problem with a win api funciton setsockopt() :/
i inherited the QTcpSocket and set an option to the socket
SOCKET s = this->socketDescriptor();
BOOL bOptVal = FALSE;
int bOptLen = sizeof (BOOL);
setsockopt(s, SOL_SOCKET, SO_DONTLINGER, (char *) &bOptVal, bOptLen);
is it possible to set the SO_DONTLINGER option with qt?