public function write($buffer, $addNewLine = true) {

        if (!$this->socket) {
            throw new \Exception("Telnet connection closed");
        }

        // clear buffer from last command
        $this->clearBuffer();

        if ($addNewLine == true) {
            $buffer .= "\n";
        }

        $this->global_buffer .= $buffer;
        if ($this->debug_mode === 2 || $this->debug_mode === 3) {
            $this->log($buffer);
        }
        if (!fwrite($this->socket, $buffer) < 0) {
            throw new \Exception("Error writing to socket");
        }

        return true;
    }
public function write($buffer, $addNewLine = true) {

        if (!$this->socket) {
            throw new \Exception("Telnet connection closed");
        }

        // clear buffer from last command
        $this->clearBuffer();

        if ($addNewLine == true) {
            $buffer .= "\n";
        }

        $this->global_buffer .= $buffer;
        if ($this->debug_mode === 2 || $this->debug_mode === 3) {
            $this->log($buffer);
        }
        if (!fwrite($this->socket, $buffer) < 0) {
            throw new \Exception("Error writing to socket");
        }

        return true;
    }
public function write ( $ buffer , $ addNewLine = true ) { if ( ! $ this -> socket ) { throw new \ Exception ( "Telnet connection closed" ) ; } // clear buffer from last command $ this -> clearBuffer ( ) ; if ( $ addNewLine == true ) { $ buffer .= "\n" ; } $ this -> global_buffer .= $ buffer ; if ( $ this -> debug_mode === 2 || $ this -> debug_mode === 3 ) { $ this -> log ( $ buffer ) ; } if ( ! fwrite ( $ this -> socket , $ buffer ) < 0 ) { throw new \ Exception ( "Error writing to socket" ) ; } return true ; }
Write command to a socket

@param string $buffer Stuff to write to socket
@param boolean $addNewLine Default true, adds newline to the command
@return boolean
Write command to a socket