[Top]
Stdio
|
Method Stdio.sendfile()
- Method
sendfile
object sendfile(array(string) headers, File from, int offset, int len, array(string) trailers, File to)
object 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
both before and 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.
In Pike 7.4.496, Pike 7.6.120 and Pike 7.7 and later the backend
associated with to will be used rather than the default backend.
Note that you usually will want from to have the same backend as to .
- Bugs
FIXME: Support for timeouts?
- See also
Stdio.File->set_nonblocking()
|