src/ResourceSocket.php
function end($data = null) {
        if(!$this->writable) {
            return;
        }
        
        $this->closing = true;
        $this->readable = false;
        
        $this->pause();
        
        if($data !== null && $data !== '') {
            $this->write($data);
        }
        
        $this->writable = false;
        
        $cb = function () use (&$cb) {
            if($this->data === '') {
                return $this->close();
            }
            
            $this->loop->futureTick($cb);
        };
        
        $this->loop->futureTick($cb);
    }
function end($data = null) {
        if(!$this->writable) {
            return;
        }
        
        $this->closing = true;
        $this->readable = false;
        
        $this->pause();
        
        if($data !== null && $data !== '') {
            $this->write($data);
        }
        
        $this->writable = false;
        
        $cb = function () use (&$cb) {
            if($this->data === '') {
                return $this->close();
            }
            
            $this->loop->futureTick($cb);
        };
        
        $this->loop->futureTick($cb);
    }
Successfully ends the stream (after optionally sending some final data).
@param mixed|string|null  $data
@return void