src/Socket.php
public function write(?string $data = null): void
    {
        if ($data !== null) {
            $this->writeBuffer .= $data;
        }

        $bytesToWrite = strlen($this->writeBuffer);
        $bytesWritten = @fwrite($this->stream, $this->writeBuffer);

        if ($bytesToWrite === $bytesWritten) {
            Loop::disable($this->writeWatcherId);
        } elseif ($bytesWritten >= 0) {
            Loop::enable($this->writeWatcherId);
        } elseif ($this->isSocketDead()) {
            $this->reconnect();
        }

        $this->writeBuffer = substr($this->writeBuffer, $bytesWritten);
    }
public function write(?string $data = null): void
    {
        if ($data !== null) {
            $this->writeBuffer .= $data;
        }

        $bytesToWrite = strlen($this->writeBuffer);
        $bytesWritten = @fwrite($this->stream, $this->writeBuffer);

        if ($bytesToWrite === $bytesWritten) {
            Loop::disable($this->writeWatcherId);
        } elseif ($bytesWritten >= 0) {
            Loop::enable($this->writeWatcherId);
        } elseif ($this->isSocketDead()) {
            $this->reconnect();
        }

        $this->writeBuffer = substr($this->writeBuffer, $bytesWritten);
    }
Write to the socket.

@throws Loop\InvalidWatcherError