Example #1
0
 /**
  * Connection cleanup callback
  * 
  * @param integer $id The client's ID
  * 
  * @return void
  */
 function onCleanup($id)
 {
     $client = $this->clients[$id];
     $post = array("m" => $this->module, "dosql" => $this->controller, "port" => $this->port, "message" => base64_encode("TCP_Closed"), "client_addr" => $client["addr"], "client_port" => $client["port"], "suppressHeaders" => 1);
     $url = $this->call_url . "/index.php?login={$this->username}:{$this->password}";
     $this->requestHttpPost($url, $post);
     parent::onCleanup($id);
 }
                default:
                    return;
            }
            $response = CSocketBasedServer::send("localhost", $port, $server_class::sampleMessage());
            echo "<pre class='er7'>{$response}</pre>";
            return;
        } catch (Exception $e) {
            CAppUI::displayAjaxMsg($e->getMessage(), UI_MSG_ERROR);
        }
        break;
    case "stats":
        try {
            mbTrace(json_decode(CSocketBasedServer::send("localhost", $port, "__" . strtoupper($action) . "__\n"), true));
        } catch (Exception $e) {
            CAppUI::stepAjax($e->getMessage(), UI_MSG_ERROR);
        }
        return;
    default:
        CAppUI::displayAjaxMsg("Unknown command '{$action}'", UI_MSG_ERROR);
}
$processes = CSocketBasedServer::getPsStatus();
$process_id = CValue::get("process_id");
if (!array_key_exists($process_id, $processes)) {
    return;
}
// Création du template
$smarty = new CSmartyDP();
$smarty->assign("process_id", $process_id);
$smarty->assign("uid", $uid);
$smarty->assign("_process", $processes[$process_id]);
$smarty->display("inc_server_socket.tpl");
Example #3
0
        $server_class = "CDicomServer";
        $class_path = dirname(__FILE__) . "/../modules/dicom/classes/{$server_class}.class.php";
        break;
    case "mllp":
        $server_type = "MLLP";
        $server_class = "CMLLPServer";
        $class_path = dirname(__FILE__) . "/../modules/hl7/classes/{$server_class}.class.php";
        break;
    case "http_proxy":
        $server_type = "HTTP_proxy";
        $server_class = "CHTTPTunnel";
        $class_path = dirname(__FILE__) . "/../modules/system/classes/{$server_class}.class.php";
        break;
    default:
        echo "Incorrect server type specified!\n";
        exit(0);
}
require_once $class_path;
$tmp_dir = CSocketBasedServer::getTmpDir();
/**
 * Simple output function
 * 
 * @param string $str The string to output
 * 
 * @return void
 */
function outln($str)
{
    $stdout = fopen("php://stdout", "w");
    fwrite($stdout, $str . PHP_EOL);
}
 /**
  * Send a request
  *
  * @param string  $host    The client's IP to send the request to
  * @param integer $port    The client's port number
  * @param string  $message The message to send
  *
  * @throws Exception
  * @return string The client's response
  */
 static function send($host, $port, $message)
 {
     $root_dir = dirname(__FILE__);
     include_once "{$root_dir}/SocketClient.class.php";
     try {
         if (!self::$client) {
             self::$client = new SocketClient();
             self::$client->connect($host, $port);
         }
         return self::$client->sendAndReceive($message);
     } catch (Exception $e) {
         throw $e;
     }
 }