Makes data sending asynchronous for stream/sockets resources.
Note:
If data is continuously written to a socket but the peer cannot read fast enough, the socket buffer
will eventually fill up. In this case, the Swoole underlying layer will store the excess data
in an in-memory buffer and wait for the writable event to trigger before attempting to write
to the socket again. However, if the in-memory buffer also becomes full, Swoole will throw a
"pipe buffer overflow, reactor will block" error and switch to blocking mode, pausing further
writes until space becomes available.
Note:
The buffer-full return of false is an atomic operation—it guarantees
either complete success (all data written) or total failure (nothing written).
Warning
Event::write cannot be used with SSL/TLS-encrypted streams or sockets (tunneled connections).
Warning
Upon successful execution, Event::write will automatically switch the $socket to non-blocking mode.
Parameters
fd
File descriptor (stream/socket resource, integer, or object).
data
Data to send (length must not exceed socket buffer size).