buffering

What does "select((select(s),$|=1)[0])" do in Perl?

I've seen some horrific code written in Perl but I can't make head or tail of this one. It's in some networking code that we use to communicate with a server and I assume it's something to do with buffering (since it sets $|). But I can't figure out why there's multiple selects or the array reference. Can anyone help me out? ...

Win32: Write to file without buffering ?

I need to create a new file handle so that any write operations to that handle get written to disk immediately. Extra info: The handle will be the inherited STDOUT of a child process, so I need any output from that process to immediately be written to disk. Studying the CreateFile documentation, the FILE_FLAG_WRITE_THROUGH flag looked...

Buffering a media content, while playing the other one in Windows Media Player using C#

I am developing an application in C# that has a form with Windows Media Player embedded inside. There are several links to some online content in my app. and I want user to change the content from one to another with a button click. Since WMP spent some time while buffering for the next content, I want to continue playing the current con...

How to log make output without buffering from stdout and stderr

I am having a problem with logging to output from an automated build. The build is done with a Makefile and the makefile utility. The problem is that normal output like compiler command lines go to stdout and compile errors go to stderr. I want to get the output from the build as it would show on the screen. So something like: (stdou...

is there COMMIT analog in python for writing into a file?

I have a file open for writing, and a process running for days -- something is written into the file in relatively random moments. My understanding is -- until I do file.close() -- there is a chance nothing is really saved to disk. Is that true? What if the system crashes when the main process is not finished yet? Is there a way to do k...

video streaming asp.net

Hi, i've been making an asp website in which i'm providing the user a facility to upload videos and view them once they are uploaded. I've been successfully been able to upload videos to my server, but not getting as how to play it on the client's page. I want to buffer the video and stream it on user's browser, don't want him to wait an...

Using Core Graphics/ Cocoa, can you draw to a bitmap context from a background thread?

I'm drawing offscreen to a CGContext created using CGBitmapContextCreate, then later generating a CGImage from it with CGBitmapContextCreateImage and drawing that onto my view in drawRect (I'm also drawing some other stuff on top of that - this is an exercise in isolating different levels of variability and complexity). This all works f...

How does 2 or more processes interact with the keyboard?

Hello. I have been thinking alot over keyboard handling. How does it work? I cant seem to google me to a good explaining. I know that a keyboard interrupt is made every time a key is pressed. The processor halts whatever it is processing and load the keyboard data from the keyboard buffer, storing it in a system level buffer. But what ha...

In php, I want to download an s3 file to the browser without storing it on my server

I've got files on Amazon's S3. They are named with a unique ID so there are no duplicates. I am accessing them using an authorized URL. I need to be able to pass them through to the browser, but I need to rename them. Right now I'm using fopen, but it is downloading the file to my server before serving the file to the browser. How can I ...

Python sockets buffering

Let's say I want to read a line from a socket, using the standard socket module: def read_line(s): ret = '' while True: c = s.recv(1) if c == '\n' or c == '': break else: ret += c return ret What exactly happens in s.recv(1)? Will it issue a system call each time? I guess ...

Inspecting C pipelines passing through a program -- border cases

Hi there, I'm receiving from socket A and writing that to socket B on the fly (like a proxy server might). I would like to inspect and possibly modify data passing through. My question is how to handle border cases, ie where the regular expression I'm searching for would match between two successive socket A read and socket B write iter...

Is it possible to get unbuffered web browser output?

I have a small cgi script that fetches and validates a configuration file for Nagios. The typical run time is several minutes, and I would like to get some feedback in the browser during the run. To illustrate what I would like to happen, consider this: #!/bin/sh echo "Content-type: text/plain" echo for i in A B C D E do echo...

How to buffer stdout in memory and write it from a dedicated thread

I have a C application with many worker threads. It is essential that these do not block so where the worker threads need to write to a file on disk, I have them write to a circular buffer in memory, and then have a dedicated thread for writing that buffer to disk. The worker threads do not block any more. The dedicated thread can saf...

Flex: stop loading a VideoDisplay whitout losing loaded buffer

Hi, Is there a way to stop the download of a flv file started by the VideoDisplay object after calling the VideoDisplay.load() method ? And most important : without losing the previously loaded data. By that I mean that VideoDisplay.close() won't work for me. When I play the video after calling the close() method the request to the flv...

Turn off buffering in pipe

I have a script which calls two commands: long_running_command | print_progress The long_running_command prints a progress but I'm unhappy with it. I'm using print_progress to make it more nice (namely, I print the progress in a single line). The problem: The pipe activates a 4K buffer, to the nice print program gets nothing ... noth...

Does Perl's $| setting affect system commands?

I am looking at some old code in Perl, where the author has writtern $| = 1 in the first line. But the code does not have any print statements, it calls a C++ binary using the system command. Now I read that $| will force flush after every print. So does it affect the system command's output in any way or am I safe to remove that line....

How to buffer output from a .net BackgroundWorker ?

I have a stream of data coming in from an external source which I currently collect in a BackgroundWorker. Each time it gets another chunk of data, it presents that data to a GUI using a ReportProgress() call. I get the impression that the ProgressChanged function is just a synchronisation mechanism though so when my worker thread calls...

JAVA NIO ByteBuffer allocatation to fit largest dataset?

I'm working on an online game and I've hit a little snag while working on the server side of things. When using nonblocking sockets in Java, what is the best course of action to handle complete packet data sets that cannot be processed until all the data is available? For example, sending a large 2D tiled map over a socket. I can think...

Is Socket.BeginReceive(IList<ArraySegment<byte>> buffers.. Not Asynchronous?

Hi all, I have been looking to implement a custom class of : IList<ArraySegment<byte>> this will be passed to a socket, and used as the buffer to receive data from that Socket. Socket.BeginReceive( IList<ArraySegment<Byte>>, SocketFlags, AsyncCallback, Object ) MSDN Documentation While testing I have found that when calli...

What is the best way to cache files in php?

hi , i'm using Smarty with my php code and i like to cache some of website pages so i used the following code : // TOP of script ob_start(); // start the output buffer $cachefile ="cache/cachefile.html"; // normal PHP script $smarty->display('somefile.tpl.html') ; $fp = fopen($cachefile, 'w'); // open the cache file for writing fwri...