當前位置: 首頁>>代碼示例>>PHP>>正文


PHP stream_socket_sendto函數代碼示例

本文整理匯總了PHP中stream_socket_sendto函數的典型用法代碼示例。如果您正苦於以下問題:PHP stream_socket_sendto函數的具體用法?PHP stream_socket_sendto怎麽用?PHP stream_socket_sendto使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了stream_socket_sendto函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: query

    public function query($text)
    {
        $head = <<<_HEADER_
<?xml version="1.0" ?>
<wordsegmentation version="0.1">
<option showcategory="1" />
<authentication username="{$this->user}" password="{$this->passwd}" />
<text>
_HEADER_;
        $footer = <<<_FOOT_
</text>
</wordsegmentation>
_FOOT_;
        $this->data_send = $text;
        $text = str_replace("&", " ", $text);
        $querystr = $head . $text . $footer;
        $tempxml = simplexml_load_string($querystr);
        $resp = array();
        if ($tempxml) {
            if (stream_socket_sendto($this->sock, $tempxml->asXML())) {
                do {
                    $ttt = stream_socket_recvfrom($this->sock, 65525);
                    $ttt = iconv('big5', 'utf-8', $ttt);
                    $resp[] = $ttt;
                } while (!simplexml_load_string(implode($resp)));
                return $this->data_recv = html_entity_decode(implode($resp));
            }
        } else {
            $this->data_recv = 0;
            return null;
        }
    }
開發者ID:balduran,項目名稱:CKIP-interface-for-PHP,代碼行數:32,代碼來源:CKIP.php

示例2: processMessage

 public function processMessage($message, $client)
 {
     $event = $message->event;
     $data = $message->data;
     $uuid = $message->uuid;
     if ($event == "beforeEach") {
         $data = $this->runner->runBeforeEachHooksForTransaction($data);
         $data = $this->runner->runBeforeHooksForTransaction($data);
     }
     if ($event == "beforeEachValidation") {
         $data = $this->runner->runBeforeEachValidationHooksForTransaction($data);
         $data = $this->runner->runBeforeValidationHooksForTransaction($data);
     }
     if ($event == "afterEach") {
         $data = $this->runner->runAfterHooksForTransaction($data);
         $data = $this->runner->runAfterEachHooksForTransaction($data);
     }
     if ($event == "beforeAll") {
         $data = $this->runner->runBeforeAllHooksForTransaction($data);
     }
     if ($event == "afterAll") {
         $data = $this->runner->runAfterAllHooksForTransaction($data);
     }
     $messageToSend = ['uuid' => $uuid, 'data' => $data, 'event' => $event];
     $messageToSend = json_encode($messageToSend);
     stream_socket_sendto($client, $messageToSend . self::MESSAGE_END);
 }
開發者ID:ddelnano,項目名稱:dredd-hooks-php,代碼行數:27,代碼來源:Server.php

示例3: _send_udp

 /**
  * 發送UDP數據包
  * @param $data
  * @param $port
  */
 static function _send_udp($data, $port)
 {
     if (self::$enable) {
         $cli = stream_socket_client('udp://' . self::$sc_svr_ip . ':' . $port, $errno, $errstr);
         stream_socket_sendto($cli, $data);
     }
 }
開發者ID:google2013,項目名稱:StatsCenter,代碼行數:12,代碼來源:StatsCenter.php

示例4: close_moniter

 public function close_moniter()
 {
     $dmainid = trim($_POST['dmainid']);
     //$dmain = trim($_POST['dmain']);
     $dmain_list_db = new Dmain_list();
     $val = $dmain_list_db->close_moniter($dmainid);
     $list = [];
     if (is_array($val) && count($val) > 0) {
         foreach ($val as $value) {
             $list[] = $value->dmain;
         }
     }
     if (count($list) > 0) {
         $list = implode('|', $list);
     } else {
         $list = '';
     }
     //寫入redis共享給udp服務器
     $redis = $this->getRedis();
     $dmain_list = $redis->set('dmain', $list);
     $socket = stream_socket_client('udp://211.151.98.92:9501');
     $data = ['control' => 'reload'];
     $data = json_encode($data) . '\\r\\n';
     if (!$socket) {
         exit(json_encode(false));
     } else {
         stream_socket_sendto($socket, $data);
         exit(json_encode(true));
     }
 }
開發者ID:sniperwzq,項目名稱:moniter-client,代碼行數:30,代碼來源:setmoniter.php

示例5: write

 /**
  * {@inheritdoc}
  */
 public function write($string)
 {
     if (!$this->isWritable()) {
         throw new RuntimeException("Stream is not writable");
     }
     return stream_socket_sendto($this->getContext(), $string);
 }
開發者ID:Talesoft,項目名稱:tale-net,代碼行數:10,代碼來源:SocketBase.php

示例6: write

 /**
  * {@inheritdoc}
  */
 public function write($data = null)
 {
     if (isset($this->stream) === false) {
         $this->createStream();
     }
     @stream_socket_sendto($this->stream, $data);
     return true;
 }
開發者ID:influxdb,項目名稱:influxdb-php,代碼行數:11,代碼來源:UDP.php

示例7: sendData

 /**
  * 發送數據給統計係統
  * @param string $address
  * @param string $buffer
  * @return boolean
  */
 public static function sendData($address, $buffer)
 {
     $socket = stream_socket_client($address);
     if (!$socket) {
         return false;
     }
     return stream_socket_sendto($socket, $buffer) == strlen($buffer);
 }
開發者ID:shitfSign,項目名稱:workerman-game,代碼行數:14,代碼來源:StatisticClient.php

示例8: write

 /**
  * Send the data
  *
  * @param $data
  *
  * @return mixed
  */
 public function write($data = null)
 {
     $host = sprintf('udp://%s:%d', $this->config['host'], $this->config['port']);
     // stream the data using UDP and suppress any errors
     $stream = @stream_socket_client($host);
     @stream_socket_sendto($stream, $data);
     @fclose($stream);
     return true;
 }
開發者ID:greggcz,項目名稱:librenms,代碼行數:16,代碼來源:UDP.php

示例9: sendData

 /**
  * 發送數據給統計係統
  * @param string $address        	
  * @param string $buffer        	
  * @return boolean
  */
 public static function sendData($address, $buffer, $timeout = 10)
 {
     $socket = stream_socket_client('tcp://' . $address, $errno, $errmsg, $timeout);
     if (!$socket) {
         return false;
     }
     stream_set_timeout($socket, $timeout);
     return stream_socket_sendto($socket, $buffer) == strlen($buffer);
 }
開發者ID:smalleyes,項目名稱:statistics,代碼行數:15,代碼來源:StatisticClient.php

示例10: request

 function request($request)
 {
     try {
         $dt = call_user_func($this->callback, NULL, $request);
         if (!empty($dt['data'])) {
             stream_socket_sendto($this->srv, $dt['data'], 0, $this->cli);
         }
     } catch (Exception $e) {
         cy_log(CYE_ERROR, "exception while processing.");
     }
 }
開發者ID:xiaoyjy,項目名稱:retry,代碼行數:11,代碼來源:hb.php

示例11: run

 public function run()
 {
     $result = $this->_server->parse($this->_data);
     if (empty($result['a'])) {
         $data = $this->_data;
     } else {
         $this->_server = $this->route($this->_server);
         $data = $this->_server->getData();
     }
     \stream_socket_sendto($this->_conn, $data . "\n");
 }
開發者ID:jxw7733,項目名稱:zphpdemo,代碼行數:11,代碼來源:ReactThread.php

示例12: send

 /**
  * Sends data on the connection.
  *
  * @param string $send_buffer
  * @param bool   $raw
  * @return void|boolean
  */
 public function send($send_buffer, $raw = false)
 {
     if (false === $raw && $this->protocol) {
         $parser = $this->protocol;
         $send_buffer = $parser::encode($send_buffer, $this);
         if ($send_buffer === '') {
             return null;
         }
     }
     return strlen($send_buffer) === stream_socket_sendto($this->_socket, $send_buffer, 0, $this->_remoteAddress);
 }
開發者ID:walkor,項目名稱:workerman,代碼行數:18,代碼來源:UdpConnection.php

示例13: pingUdp

 protected function pingUdp($target, $data)
 {
     if (!$this->monSocket) {
         $this->monSocket = stream_socket_client($target, $errno, $errstr);
     }
     if ($this->monSocket) {
         $post = http_build_query($data, '', '&');
         stream_socket_sendto($this->monSocket, $post);
     } else {
         common_log(LOG_ERR, __METHOD__ . " UDP logging fail: {$errstr}");
     }
 }
開發者ID:microcosmx,項目名稱:experiments,代碼行數:12,代碼來源:queuemonitor.php

示例14: add

    public function add($response)
    {
        $contentLength = strlen($response);
        $httpResponse = 'HTTP/1.0 200 OK
Date: ' . (new \DateTime())->format(\DateTIme::RFC822) . '
Server: PHP Robot Framework Remote Server
Connection: close
Content-Type: text/xml
Content-Length: ' . $contentLength . "\r\n" . "\r\n" . $response;
        stream_socket_sendto($this->requestSocket, $httpResponse);
        stream_socket_shutdown($this->requestSocket, STREAM_SHUT_RDWR);
    }
開發者ID:jplambert,項目名稱:phrrs,代碼行數:12,代碼來源:SocketInterface.php

示例15: writeSync

 public function writeSync($data)
 {
     if ($this->writeEvent) {
         $this->loop->removeWriteStream($this->connection);
         $this->writeEvent = false;
     }
     $this->dataBuffer .= $this->buffer->encodeMessage(serialize($data));
     while (strlen($this->dataBuffer) > 0) {
         $this->ThrowOnConnectionInvalid();
         $dataWritten = stream_socket_sendto($this->connection, $this->dataBuffer);
         $this->dataBuffer = substr($this->dataBuffer, $dataWritten);
     }
 }
開發者ID:RogerWaters,項目名稱:react-thread-pool,代碼行數:13,代碼來源:ThreadConnection.php


注:本文中的stream_socket_sendto函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。