Stopping data transfer with QTcpSocket
-
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.
-
[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.
-
ok i solved this problem with a win api funciton setsockopt() :/
i inherited the QTcpSocket and set an option to the socket
@
#ifdef WIN32
#include <Winsock2.h>
#endif#include "qmytcpsocket.h"
void QMyTcpSocket::abort()
{
#ifdef WIN32
SOCKET s = this->socketDescriptor();
BOOL bOptVal = FALSE;
int bOptLen = sizeof (BOOL);
setsockopt(s, SOL_SOCKET, SO_DONTLINGER, (char *) &bOptVal, bOptLen);
#endif
TcpSocket::abort();
}@
is it possible to set the SO_DONTLINGER option with qt?