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. Reading from text file during write on it

Reading from text file during write on it

Scheduled Pinned Locked Moved Unsolved General and Desktop
9 Posts 5 Posters 1.1k Views 2 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.
  • zhmhZ Offline
    zhmhZ Offline
    zhmh
    wrote on last edited by zhmh
    #1

    Is it possible with 2 separate programs to read and write data in a single file at same time? One of those is added data to the text file with thread , and the other program reads information with thread from the same file at the same time, the added data is always in progress, but reading data can be done every few seconds. Is it possible?

    JonBJ kshegunovK 2 Replies Last reply
    0
    • zhmhZ zhmh

      Is it possible with 2 separate programs to read and write data in a single file at same time? One of those is added data to the text file with thread , and the other program reads information with thread from the same file at the same time, the added data is always in progress, but reading data can be done every few seconds. Is it possible?

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @zhmh
      Don't know, sounds hairy! But this is what sockets (or pipes or other ipc), not files, are for....

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi,

        Are you thinking of something like the tail -f Linux command ?

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        JonBJ zhmhZ 2 Replies Last reply
        3
        • SGaistS SGaist

          Hi,

          Are you thinking of something like the tail -f Linux command ?

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by
          #4

          @SGaist Ummmm, good point!

          1 Reply Last reply
          0
          • SGaistS SGaist

            Hi,

            Are you thinking of something like the tail -f Linux command ?

            zhmhZ Offline
            zhmhZ Offline
            zhmh
            wrote on last edited by
            #5
            This post is deleted!
            1 Reply Last reply
            0
            • zhmhZ zhmh

              Is it possible with 2 separate programs to read and write data in a single file at same time? One of those is added data to the text file with thread , and the other program reads information with thread from the same file at the same time, the added data is always in progress, but reading data can be done every few seconds. Is it possible?

              kshegunovK Offline
              kshegunovK Offline
              kshegunov
              Moderators
              wrote on last edited by
              #6

              It's possible (on linux), but the point is your design choice is bad. You should use something (i.e. @JonB's IPC) that you have control over. What would happen if I delete or move the file while you're reading or writing? What'd you expect to see in the moved file, after the reading/writing completed ...?

              Read and abide by the Qt Code of Conduct

              zhmhZ 1 Reply Last reply
              1
              • kshegunovK kshegunov

                It's possible (on linux), but the point is your design choice is bad. You should use something (i.e. @JonB's IPC) that you have control over. What would happen if I delete or move the file while you're reading or writing? What'd you expect to see in the moved file, after the reading/writing completed ...?

                zhmhZ Offline
                zhmhZ Offline
                zhmh
                wrote on last edited by zhmh
                #7

                @kshegunov I use QT on Raspberry Pi with raspbian OS,I tested tail command and it's ok, for some reason I used two programs and I want to read data of text file and send it to the web server with QHttp protocol( not sending all data at one time), I need to save data in Pi memory

                JonBJ 1 Reply Last reply
                0
                • zhmhZ zhmh

                  @kshegunov I use QT on Raspberry Pi with raspbian OS,I tested tail command and it's ok, for some reason I used two programs and I want to read data of text file and send it to the web server with QHttp protocol( not sending all data at one time), I need to save data in Pi memory

                  JonBJ Offline
                  JonBJ Offline
                  JonB
                  wrote on last edited by JonB
                  #8

                  @zhmh
                  So (under Linux) you seem to be left with two choices: implement something which does what tail -f does if you really want be file-based, or use IPC (sockets, named pipes, ...).

                  1 Reply Last reply
                  0
                  • VRoninV Offline
                    VRoninV Offline
                    VRonin
                    wrote on last edited by
                    #9

                    This examples uses a buffer in memory but the concept is identical with files

                    "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
                    ~Napoleon Bonaparte

                    On a crusade to banish setIndexWidget() from the holy land of 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