当前位置: 首页>>代码示例>>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;未经允许,请勿转载。