Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Stopping data transfer with QTcpSocket
Forum Updated to NodeBB v4.3 + New Features

Stopping data transfer with QTcpSocket

Scheduled Pinned Locked Moved General and Desktop
7 Posts 3 Posters 5.7k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    sryyy
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    • L Offline
      L Offline
      lycis
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      0
      • L Offline
        L Offline
        leon.anavi
        wrote on last edited by
        #3

        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.

        http://anavi.org/

        1 Reply Last reply
        0
        • S Offline
          S Offline
          sryyy
          wrote on last edited by
          #4

          yes i used abort but windows sends the data furthermore

          1 Reply Last reply
          0
          • L Offline
            L Offline
            leon.anavi
            wrote on last edited by
            #5

            [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.

            http://anavi.org/

            1 Reply Last reply
            0
            • S Offline
              S Offline
              sryyy
              wrote on last edited by
              #6

              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 :/

              1 Reply Last reply
              0
              • S Offline
                S Offline
                sryyy
                wrote on last edited by
                #7

                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?

                1 Reply Last reply
                0

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved