PHPDaemon\Network\IOStream::write PHP Method

write() public method

Send data to the connection. Note that it just writes to buffer that flushes at every baseloop
public write ( string $data ) : boolean
$data string Data to send
return boolean Success
    public function write($data)
    {
        if (!$this->alive) {
            Daemon::log('Attempt to write to dead IOStream (' . get_class($this) . ')');
            return false;
        }
        if (!isset($this->bev)) {
            return false;
        }
        if (!mb_orig_strlen($data)) {
            return true;
        }
        $this->writing = true;
        Daemon::$noError = true;
        if (!$this->bev->write($data) || !Daemon::$noError) {
            $this->close();
            return false;
        }
        return true;
    }

Usage Example

Beispiel #1
0
 /**
  * Send data to the connection. Note that it just writes to buffer that flushes at every baseloop
  * @param  string  $data Data to send
  * @return boolean       Success
  */
 public function write($data)
 {
     if ($this->dgram) {
         return $this->parentSocket->sendTo($data, $this->finished ? MSG_EOF : 0, $this->host, $this->port);
     }
     return parent::write($data);
 }