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. How can I add a progress for message sending operation (smtp) with blocking sockets API's?
Servers for Qt installer are currently down

How can I add a progress for message sending operation (smtp) with blocking sockets API's?

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 471 Views
  • 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.
  • M Offline
    M Offline
    meteoir
    wrote on 5 Jun 2018, 11:30 last edited by
    #1

    Hello!
    I'm using blocking sockets API (waitFor* functions) for sending mail by smtp protocol (it's a DLL modue). All operations are synchronous: connect->waitForConnected(timeout)->login->waitForReadyRead(timeout)->sendMessage->waitForBytesWritten(timeout)->etc.
    I'm using blocking API, because QCoreApplication absence is required (DLL used by different apps, incl. non-qt-based). Blocking functions don't require event loop and it works fine.
    But how can I make a visual progress for long-term sending mail operations (with big attachment, for example)?
    And how can organize callbacks for progress notifications in sendmail DLL?

    ps: all blocking waitFor* functions marked as
    functions, that may fail randomly on Windows. Consider using the event loop and the readyRead() signal if your software will run on Windows.
    Why?

    J 1 Reply Last reply 5 Jun 2018, 12:01
    0
    • M meteoir
      5 Jun 2018, 11:30

      Hello!
      I'm using blocking sockets API (waitFor* functions) for sending mail by smtp protocol (it's a DLL modue). All operations are synchronous: connect->waitForConnected(timeout)->login->waitForReadyRead(timeout)->sendMessage->waitForBytesWritten(timeout)->etc.
      I'm using blocking API, because QCoreApplication absence is required (DLL used by different apps, incl. non-qt-based). Blocking functions don't require event loop and it works fine.
      But how can I make a visual progress for long-term sending mail operations (with big attachment, for example)?
      And how can organize callbacks for progress notifications in sendmail DLL?

      ps: all blocking waitFor* functions marked as
      functions, that may fail randomly on Windows. Consider using the event loop and the readyRead() signal if your software will run on Windows.
      Why?

      J Offline
      J Offline
      JonB
      wrote on 5 Jun 2018, 12:01 last edited by
      #2

      @meteoir
      I assume that since they are blocking and don't use event loop you won't have the GUI updated.

      I presume two possibilities:

      • Make timeout small, and expect to call functions repeatedly, with GUI update/progress after each timeout expires.

      • Put blocking calls into separate thread from GUI.

      1 Reply Last reply
      2
      • M Offline
        M Offline
        meteoir
        wrote on 5 Jun 2018, 13:52 last edited by
        #3

        mail sending functions will called in separated thread. But how can I take a progress notifications if waitForBytesWritten function is hang on or big file transferred?

        J 1 Reply Last reply 5 Jun 2018, 13:59
        0
        • M meteoir
          5 Jun 2018, 13:52

          mail sending functions will called in separated thread. But how can I take a progress notifications if waitForBytesWritten function is hang on or big file transferred?

          J Offline
          J Offline
          JonB
          wrote on 5 Jun 2018, 13:59 last edited by
          #4

          @meteoir
          Make your waitForBytesWritten() take a small timeout if you want to avoid "hang".

          However, as you say, the docs state:

          Note: This function may fail randomly on Windows. Consider using the event loop and the bytesWritten() signal if your software will run on Windows.

          so you may not be able to do what you want under Windows.

          1 Reply Last reply
          0

          1/4

          5 Jun 2018, 11:30

          • Login

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