Extracted from Pike v7.6 release 61 at 2005-12-30.
pike.ida.liu.se
[Top]
Stdio

Method Stdio.sendfile()


Method sendfile

object Stdio.sendfile(array(string) headers, File from, int offset, int len, array(string) trailers, File to)
object Stdio.sendfile(array(string) headers, File from, int offset, int len, array(string) trailers, File to, function(int:void) callback, mixed ... args)

Description

Sends headers followed by len bytes starting at offset from the file from followed by trailers to the file to . When completed callback will be called with the total number of bytes sent as the first argument, followed by args .

Any of headers , from and trailers may be left out by setting them to 0.

Setting offset to -1 means send from the current position in from .

Setting len to -1 means send until from 's end of file is reached.

Note

The sending is performed asynchronously, and may complete before or after the function returns.

For callback to be called, the backend must be active (ie main() must have returned -1, or Pike.DefaultBackend get called in some other way).

In some cases, the backend must also be active for any sending to be performed at all.

Bugs

FIXME: Support for timeouts?

See also

Stdio.File->set_nonblocking()