/** * Check if the source is reachable * * @todo Faire un vrai isReachable (envoi de CEcho) * * @return boolean */ function isReachableSource() { if (!$this->_socket_client) { $this->setSocketClient(); } if ($this->_socket_client->connect() !== null) { $this->_reachable = 0; $this->_message = CAppUI::tr("CSourceDicom-unreachable-source", $this->host); return false; } return true; }
function action_deletemsg() { if (!isset($_COOKIE['username'])) { header("Location: /"); die; } $this->model = new ModelMessage($_POST['msgid'], $_COOKIE['username'], null, 1, null, null); $res = $this->model->deleteMessage(); if ($res) { echo 'success'; $arr = array('action' => 'deletemsg', 'user' => $_COOKIE['username'], 'msgid' => $_POST['msgid']); $message = json_encode($arr); $sock = new SocketClient(); $sock->connect('localhost', 8000, '/'); $sock->sendData($message); $sock->disconnect(); } }
<?php require_once 'SocketClient.php'; /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ $sock = new SocketClient(); $sock->connect('localhost', 8000, '/'); $sock->sendData('test'); $sock->disconnect();
{ //echo "[@0:.]"; list(, $packetSize) = unpack('v', $v = fread($this->f, 2)); if (strlen($v) < 2) { throw new Exception("Error receiving a packet"); } //echo "[@1:{$packetSize}]"; list(, $packetType) = unpack('c', fread($this->f, 1)); //echo "[@2:{$packetType}]"; $packetData = $packetSize > 0 ? fread($this->f, $packetSize) : ''; //echo "[@3:{$packetData}]"; return new Packet($packetType, $packetData); } } $socketClient = new SocketClient(); $socketClient->connect('127.0.0.1', 9777); $time = time(); for ($n = 0; $n < 100000; $n++) { //for ($n = 0; $n < 1000; $n++) { //for ($n = 0; $n < 100; $n++) { //for ($n = 0; $n < 20; $n++) { $socketClient->setUserBuffer(mt_rand(0, 100000), 0, $time + mt_rand(-50, 4), mt_rand(0, 500)); } $socketClient->setUserBuffer(1000, 0, $time, 200); $socketClient->setUserBuffer(1001, 0, $time, 300); $socketClient->setUserBuffer(1000, 0, $time + 1, 300); //$socketClient->setUserBufferFlush(); printf("Position(1000):%d\n", $pos_1000 = $socketClient->locateUserPosition(1000, 0)); printf("Position(1001):%d\n", $pos_1001 = $socketClient->locateUserPosition(1001, 0)); print_r($socketClient->listItems(0, $pos_1000, 3)); print_r($socketClient->listItems(0, 0, 3));