Horde\Socket\Client::write PHP Метод

write() публичный Метод

Writes data to the stream.
public write ( string $data )
$data string Data to write.
    public function write($data)
    {
        $this->_checkStream();
        if (!@fwrite($this->_stream, $data)) {
            $meta_data = $this->getStatus();
            if (!empty($meta_data['timed_out'])) {
                throw new Client\Exception('Timed out writing data to socket');
            }
            throw new Client\Exception('Error writing data to socket');
        }
    }

Usage Example

Пример #1
0
 /**
  * Sends a command to the server
  *
  * @param string $cmd The command to send.
  */
 protected function _sendCmd($cmd)
 {
     $status = $this->_sock->getStatus();
     if ($status['eof']) {
         throw new Exception('Failed to write to socket: connection lost');
     }
     $this->_sock->write($cmd . "\r\n");
     $this->_debug("C: {$cmd}");
 }