/** * Useful when you need to send request data to the server immediately (for long running scripts). * You can use optional argument script_name to set custom script name. * * @param string $script_name * @return bool */ static function flush($script_name = null, $flags = null) { if (self::$enabled || get_cfg_var('pinba.enabled')) { $struct = static::get_packet_info($script_name); $message = self::prepareMessage($struct); if (null === self::$server) { self::$server = get_cfg_var('pinba.server'); } if (!self::$server) { return false; } $port = 30002; if (count($server = explode(':', self::$server)) > 1) { $port = $server[1]; $server = $server[0]; } else { $server = $server[0]; } $sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP); if (!socket_sendto($sock, $message, strlen($message), 0, $server, $port)) { /* $errorcode = socket_last_error(); $errormsg = socket_strerror($errorcode); */ return false; } } return true; }