OpenSwoole\Coroutine\Client->sendfile(...)

Latest version: pecl install openswoole-22.1.2 | composer require openswoole/core:22.1.5

Declaration

<?php OpenSwoole\Coroutine\Client->sendfile(string $filepath, int $offset = 0, int $length = 0): bool

Parameters

filename

The location of the file to send, only use an absolute file path.

offset

Offset and start point for the given file, default is the beginning.

length

The length of the data to send, default is the whole file.

Return

Returns true when successful and false when not.

Description

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.

Last updated on September 1, 2022