Join 4,000+ others and never miss out on new tips, tutorials, and more.
Latest version:
pecl install openswoole-22.1.2 | composer require openswoole/core:22.1.5
<?php OpenSwoole\Coroutine\Client->sendfile(string $filepath, int $offset = 0, int $length = 0): bool
The location of the file to send, only use an absolute file path.
Offset and start point for the given file, default is the beginning.
The length of the data to send, default is the whole file.
Returns true
when successful and false
when not.
Send file to the remote server connected socket.
This method is not supported when in UDP protocol mode.
Because you can change the offset and length of the file to send, this helps support resumable file transfers.
The client will return false
if the file does not exist and this method blocks until the entire file has been sent or if a fatal error occurs.
This is a wrapper of the Linux sendfile system call.