Beberlei\Metrics\Collector\StatsD::flush PHP Method

flush() public method

public flush ( )
    public function flush()
    {
        if (!$this->data) {
            return;
        }
        $fp = fsockopen('udp://' . $this->host, $this->port, $errno, $errstr, 1.0);
        if (!$fp) {
            return;
        }
        $level = error_reporting(0);
        foreach ($this->data as $line) {
            fwrite($fp, $this->prefix . $line);
        }
        error_reporting($level);
        fclose($fp);
        $this->data = array();
    }