fiber-interop

fiber\writable()

Wait until a stream is writable and return it.

function fiber\writable(mixed $resource, float $timeout = PHP_FLOAT_MAX): mixed

Behaviour

Same rules as readable().

Example

Source: examples/api/writable.php. Run on phasync and Revolt; the output is identical.

<?php
require __DIR__ . '/vendor/autoload.php';
use function fiber\{run, writable};
run(function () {
    [$a, $b] = stream_socket_pair(STREAM_PF_UNIX, STREAM_SOCK_STREAM, STREAM_IPPROTO_IP);
    stream_set_blocking($a, false);
    echo fwrite(writable($a, 1.0), "ping"), " bytes written\n";
});

All functions