public function read($byte_count=null)
    {

        $this->log('read from  socket');
        $buffer = '';

        if(!is_null($byte_count)) {
        //read the specified amount of data
            $buffer .= fgets($this->socket, 1024);
        } else {
        //read all the data
            while (!feof($this->socket)) {
                $buffer .= fgets($this->socket, 1024);
            }
        }


        return $buffer;
    }