private function send($payload)
    {
        $msg = $payload."\r\n";
        $len = strlen($msg);
        while (true) {
            $written = @fwrite($this->streamSocket, $msg);
            if ($written === false) {
                throw new \Exception('Error sending data');
            }

            if ($written === 0) {
                throw new \Exception('Broken pipe or closed connection');
            }

            $len = ($len - $written);
            if ($len > 0) {
                $msg = substr($msg, (0 - $len));
            } else {
                break;
            }
        }

        if ($this->debug === true) {
            printf('>>>> %s', $msg);
        }
    }
private function send($payload)
    {
        $msg = $payload."\r\n";
        $len = strlen($msg);
        while (true) {
            $written = @fwrite($this->streamSocket, $msg);
            if ($written === false) {
                throw new \Exception('Error sending data');
            }

            if ($written === 0) {
                throw new \Exception('Broken pipe or closed connection');
            }

            $len = ($len - $written);
            if ($len > 0) {
                $msg = substr($msg, (0 - $len));
            } else {
                break;
            }
        }

        if ($this->debug === true) {
            printf('>>>> %s', $msg);
        }
    }
private function send ( $ payload ) { $ msg = $ payload . "\r\n" ; $ len = strlen ( $ msg ) ; while ( true ) { $ written = @ fwrite ( $ this -> streamSocket , $ msg ) ; if ( $ written === false ) { throw new \ Exception ( 'Error sending data' ) ; } if ( $ written === 0 ) { throw new \ Exception ( 'Broken pipe or closed connection' ) ; } $ len = ( $ len - $ written ) ; if ( $ len > 0 ) { $ msg = substr ( $ msg , ( 0 - $ len ) ) ; } else { break ; } } if ( $ this -> debug === true ) { printf ( '>>>> %s' , $ msg ) ; } }
Sends data thought the stream.

@param string $payload Message data.

@throws \Exception Raises if fails sending data.
@return void
Sends data thought the stream .