Questions tagged [io-buffering]
29 questions
133
votes
14 answers
34
votes
2 answers
Understanding Ruby and OS I/O buffering
How does IO buffering work in Ruby? How often is data flushed to the underlying stream when using the IO and File classes? How does this compare to OS buffering? What needs to be done to guarantee that given data has been written to disk, before…

jrdioko
- 32,230
- 28
- 81
- 120
24
votes
11 answers
How do I flush a file in Perl?
I have Perl script which appends a new line to the existing file every 3 seconds. Also, there is a C++ application which reads from that file.
The problem is that the application begins to read the file after the script is done and file handle is…

Mihran Hovsepyan
- 10,810
- 14
- 61
- 111
13
votes
1 answer
Lisp format and force-output
I don't understand why this code behaves differently in different implementations:
(format t "asdf")
(setq var (read))
In CLISP it behaves as would be expected, with the prompt printed followed by the read, but in SBCL it reads, then outputs. I…

Robert Mason
- 3,949
- 3
- 31
- 44
9
votes
3 answers
Can I stop std::cout flushing on "\n"?
According to to this post std::cout will automatically flush on \n when it is attached to an interactive device (e.g. a terminal window). Otherwise (e.g. when being piped to a file) it will act fully buffered and will only flush on .flush() or…

pauldoo
- 18,087
- 20
- 94
- 116
5
votes
1 answer
How to read character-wise on the standard input in Erlang
I'm trying to code a basic video-game and would like the input to be entered from the keyboard. Therefore, I need to read the characters on the standard input as they are produced.
Because of the buffering, io:get_chars, io:fread will return only…

Daiwen
- 727
- 1
- 4
- 15
5
votes
1 answer
Is there any way to find the buffer size of a file object
I'm trying to "map" a very large ascii file. Basically I read lines until I find a certain tag and then I want to know the position of that tag so that I can seek to it again later to pull out the associated data.
from itertools import…

mgilson
- 300,191
- 65
- 633
- 696
4
votes
3 answers
Counting the size of a text file in java while writing to the file
This question is a follow up to the accepted answer in this question. I am trying to implement the approach suggested by Aaron : Wrapping the FileOutputStream to include the logic to keep a count of the no.of bytes written so far. However the…

Kumaran
- 309
- 4
- 11
4
votes
5 answers
Is file buffering by OS harmful?
I wrote a download library for my colleague. It writes downloaded data to files.
My colleagues found that the file stays small for a long time, even if 100 Mb data have been downloaded.
So they suggest that I should call flush() after every write()…

lilyonwind
- 159
- 1
- 5
3
votes
1 answer
Streaming web uploads to socket with Rack
I currently have a Sinatra app running in an FCGI handler. I want to write a handler that will sit within the rackup file (probably in front of the Sinatra app) and will stream big file uploads to another server via sockets (without buffering it on…

Julik
- 7,676
- 2
- 34
- 48
3
votes
1 answer
Real time read from subprocess.stdout on Windows
To emphasize, the problem is real time read instead of non-blocking read. It has been asked before, e.g. subprocess.Popen.stdout - reading stdout in real-time (again). But no satisfactory solution has been proposed.
As an example, the following…

cqdjyy01234
- 1,180
- 10
- 20
2
votes
0 answers
My wireless interface seems to buffer incoming messages and receive them periodically
i've got a problem with my wireless network interface.
It seems to work fine if i try to send packets, the troubles start when i have to receive something. It's like it bufferizes incoming packets and does not pass them to the upper layer until the…

CiccioB
- 21
- 2
2
votes
1 answer
Writing last N bytes to file opened with FILE_FLAG_NO_BUFFERING
When writing lots of sequential data to disk I found that having an internal 4MB buffer and when opening the file for writing I specify [FILE_FLAG_NO_BUFFERING][1], so that my internal buffer is used.
But that also creates a requirement to write in…

leiflundgren
- 2,876
- 7
- 35
- 53
2
votes
2 answers
Standard I/O stream -- fgets() buffering type
The book "advanced programming in unix environment" discussed pipe in chapter 15, it shows that we should pay attention to the buffering type when deal with standard I/O functions.
The buffering types for different opened standard I/O streams are…

Bin
- 980
- 2
- 12
- 24
2
votes
2 answers
What is the difference between the buffering argument to open() and the hardcoded readahead buffer size used when iterating through a file?
Inspired by this question, I'm wondering exactly what the optional buffering argument to Python's open() function does. From looking at the source, I see that buffering is passed into setvbuf to set the buffer size for the stream (and that it does…

Emily
- 5,869
- 1
- 22
- 15