private function getStream($type)
    {
        if (!isset($this->streams[$type])) {
            $this->streams[$type] = fopen($this->streamUrls[$type], $type == 'input' ? 'r' : 'w');
        }
        return $this->streams[$type];
    }