Client.php
public function getNext($class, $buffer = false, $blocking = true){

        if(!$buffer && !$blocking){
            throw new \InvalidArgumentException("If the buffer is not used, blocking mode must be enabled.");
        }

        // flush buffer
        if(!$buffer){
            stream_set_blocking($this->stream, 0);
            while(fgets($this->stream)){ }
            stream_set_blocking($this->stream, 1);
        }

        stream_set_blocking($this->stream, $blocking ? 1 : 0);

        // get next message
        while(1){
            $message = fgets($this->stream);
            if(false !== strpos($message, $class)){
                return $message;
            }
        }

    }
public function getNext($class, $buffer = false, $blocking = true){

        if(!$buffer && !$blocking){
            throw new \InvalidArgumentException("If the buffer is not used, blocking mode must be enabled.");
        }

        // flush buffer
        if(!$buffer){
            stream_set_blocking($this->stream, 0);
            while(fgets($this->stream)){ }
            stream_set_blocking($this->stream, 1);
        }

        stream_set_blocking($this->stream, $blocking ? 1 : 0);

        // get next message
        while(1){
            $message = fgets($this->stream);
            if(false !== strpos($message, $class)){
                return $message;
            }
        }

    }
Get the next message of the given class (TPV, AIS, SKY, ...)
@param string $class Classe name of the desired message
@param bool $buffer get the next message from buffer or the next one in time
@param bool $blocking use stream bocking mode or not (block until next or return null if nothing new)
@return