Questions tagged [buffering]

Buffering is a process of temporarily storing data while it is being moved from one place to another.

Buffering is a process of temporarily storing data while it is being moved from one place to another. A buffer often adjusts timing by implementing a queue (or FIFO) algorithm in memory, simultaneously writing data into the queue at one rate and reading it at another rate.

Use this tag for programming questions related to data buffer and the process of buffering.

Source: Wikipedia

493 questions
8
votes
2 answers

PHP: <<< vs ob_start

In PHP sometimes I see this: $html = <<Hello world

HTML; Normally I would have used ob_start() : ob_start(); ?>

Hello world

Jedi
  • 397
  • 2
  • 4
  • 11
7
votes
2 answers

Performance of DataInputStream\DataOutputStream

I am currently using a buffered streams to read write some files. In between I do some mathematical processing where a symbol is a byte. To read : InputStream input = new FileInputStream(outputname) input.read(byte[] b,int off,int len) To write :…
UmNyobe
  • 22,539
  • 9
  • 61
  • 90
7
votes
3 answers

How do I disable buffering in fread()?

I am reading and writing to sockets using fread() and fwrite(). These functions, I believe are for buffered input and output. Is there some way that I can disable buffering while still using these functions ? Edit : I am building a remote desktop…
AnkurVj
  • 7,958
  • 10
  • 43
  • 55
7
votes
1 answer

What is the C#/.NET equivalent of BufferedInputStream (in Java)?

What is the C# equivalent for the Java BufferedInputStream and BufferedOutputStream classes?
Kenzo
  • 1,767
  • 8
  • 30
  • 53
7
votes
2 answers

Why a script that uses threads prints extra lines occasionally?

If print s is replaced by print >>sys.stderr, s then the effect vanishes. import random, sys, time import threading lock = threading.Lock() def echo(s): time.sleep(1e-3*random.random()) # instead of threading.Timer() with lock: …
jfs
  • 399,953
  • 195
  • 994
  • 1,670
7
votes
3 answers

How do I simulate a buffered peripheral device with SwingWorker?

I'm using this exercise as a pedagogical tool to help me burn in some Java GUI programming concepts. What I'm looking for is a general understanding, rather than a detailed solution to one specific problem. I expect that coding this "right" will…
Chap
  • 3,649
  • 2
  • 46
  • 84
7
votes
4 answers

How to stream a media file using PHP?

I am trying to build an application in which i have to stream the media files (audio and video) to the browser. I am reading the file through php and send the data to browser. I am using the following code. header("Cache-Control: no-cache,…
Chetan Sharma
  • 2,539
  • 5
  • 25
  • 41
7
votes
3 answers

How is line buffering implemented for C stdio input streams?

I understand that fully buffered input can be implemented by issuing a single read syscall for a block of data possibly larger than required by the application. But I don't understand how line buffering could ever be applied to input without support…
frangio
  • 855
  • 7
  • 18
7
votes
2 answers

Reusing instances of objects vs creating new ones with every update

What are the differences and pitfalls between reusing instances of objects vs creating new ones, every time I swap buffers? Background: This is for a game engine project of mine. I am writing a TripleBuffer where I have three versions of every…
dot_Sp0T
  • 389
  • 4
  • 26
7
votes
2 answers

Buffer Size in C++

I am observing the following behavior with the C++ Std library method std::ostream::write(). For buffering the data I am making use of the following C++ API std::ofstream::rdbuf()->pubsetbuf(char* s, streamsize n) This works fine ( verified using…
Abhishek
  • 117
  • 1
  • 7
7
votes
4 answers

Streaming with Android MediaPlayer - catching errors and buffering

I'm having trouble getting MediaPlayer to be resilient when streaming from a HTTP URL. If I start playing the file, but then drop the connection (e.g. airplane mode), MediaPlayer#OnErrorListener generates what=1, extra=-17 and then shortly…
Chris
  • 585
  • 3
  • 12
  • 26
7
votes
3 answers

Buffering of standard I/O library

In the book Advanced Programming in the UNIX Environments (2nd edition), the author wrote in Section 5.5 (stream operations of the standard I/O library) that: When a file is opened for reading and writing (the plus sign in the type), the following…
pjhades
  • 1,948
  • 2
  • 19
  • 34
6
votes
1 answer

setvbuf on STDOUT safe for other processes?

I am using HP-UX. I want to disable buffering on stdout to ensure that every line of code is printed in case of core dump with below command: setvbuf(stdout, NULL, _IONBF, 0); // turn off buffering for stdout In this case, does it also affect…
rApt0r
  • 61
  • 3
6
votes
2 answers

Haskell IO with interact and map

I am trying to produce an interactive Haskell program using the interact function with map. Here's what I get in ghci (as far as I can tell, that's the way all tutorials explain interact usage -- except the result). *Module> interact $ unlines . map…
notan3xit
  • 2,386
  • 2
  • 21
  • 26
6
votes
1 answer

Reduce video buffering

I'm playing video on Android using media player via RTSP. The player takes about 12s to buffer before it starts playing. Anyone know how I can convince the player to buffer less? I have full control over the RTSP server and the SDP it returns.
Philip Pearl
  • 1,523
  • 16
  • 26