当前位置: 首页>>代码示例>>PHP>>正文


PHP socket_shutdown函数代码示例

本文整理汇总了PHP中socket_shutdown函数的典型用法代码示例。如果您正苦于以下问题:PHP socket_shutdown函数的具体用法?PHP socket_shutdown怎么用?PHP socket_shutdown使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了socket_shutdown函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __destruct

 public function __destruct()
 {
     if (true === $this->isConnected()) {
         socket_shutdown($this->socket);
         socket_close($this->socket);
     }
 }
开发者ID:krowinski,项目名称:php-mysql-replication,代码行数:7,代码来源:BinLogSocketConnect.php

示例2: refresh_user

function refresh_user($discord_id)
{
    global $socket, $error;
    $so = socket_create(AF_UNIX, SOCK_DGRAM, 0);
    if ($so === false) {
        $msg = socket_strerror(socket_last_error());
        $error = "Socket failed: {$msg}";
    } else {
        $res = socket_connect($so, $socket);
        if ($res === false) {
            $msg = socket_strerror(socket_last_error());
            $error = "Connect failed: {$msg}";
        } else {
            $payload = json_encode(array('action' => 'refresh', 'user_id' => $discord_id));
            $res = socket_write($so, $payload);
            if ($res === false) {
                $error = "Socket send failed";
            } else {
                if ($res < strlen($payload)) {
                    $error = "Socket did not send all data";
                }
            }
            socket_shutdown($so);
            socket_close($so);
        }
    }
}
开发者ID:Hornwitser,项目名称:DiscordAuthorizer,代码行数:27,代码来源:forumbot.html.php

示例3: closeSocket

 /**
  * Creates a new socket
  * @return resource
  */
 static function closeSocket($sock)
 {
     $ret_val = @socket_shutdown($sock, 2);
     // Socket close doesn't return anything, so we return the result of socket_shutdown (boolean)
     @socket_close($sock);
     return $ret_val;
 }
开发者ID:hiveclick,项目名称:mojavi,代码行数:11,代码来源:Socket.php

示例4: send_request

/**
 * Send request to the daemon
 *
 * @param string $execute
 * @return string Daemon answer
 * @todo Remove error operator
 */
function send_request($execute)
{
    // @$socket = socket_create (AF_INET, SOCK_STREAM, 0);
    @($socket = socket_create(AF_UNIX, SOCK_STREAM, 0));
    if ($socket < 0) {
        $errno = "socket_create() failed.\n";
        return $errno;
    }
    // @$result = socket_connect ($socket, '127.0.0.1', 9876);
    @($result = socket_connect($socket, EasyConfig::$cfg->SOCK_EASYSCPD));
    if ($result == false) {
        $errno = "socket_connect() failed.\n";
        return $errno;
    }
    // read one line with welcome string
    socket_read($socket, 1024, PHP_NORMAL_READ);
    // $out = read_line($socket);
    // send reg check query
    // $query = $execute . "\r\n";
    $query = trim($execute) . "\n";
    socket_write($socket, $query, strlen($query));
    // read answer from the daemon
    $out = socket_read($socket, 10240, PHP_NORMAL_READ);
    socket_shutdown($socket, 2);
    socket_close($socket);
    // sleep(1);
    // todo: prüfen ob das noch benötigt wird. Wenn keine Fehler mehr auftreten kann es entfernt werden
    // usleep(250);
    return trim($out);
}
开发者ID:gOOvER,项目名称:EasySCP,代码行数:37,代码来源:easyscp-functions.php

示例5: send

 /**
  * Method send
  *
  * @param string $raw_text
  *
  * @return string $return_text
  */
 public function send($raw_text)
 {
     if (!empty($raw_text)) {
         $this->raw_text = $raw_text;
         $xw = new xmlWriter();
         $xw->openMemory();
         $xw->startDocument('1.0');
         $xw->startElement('wordsegmentation');
         $xw->writeAttribute('version', '0.1');
         $xw->startElement('option');
         $xw->writeAttribute('showcategory', '1');
         $xw->endElement();
         $xw->startElement('authentication');
         $xw->writeAttribute('username', $this->username);
         $xw->writeAttribute('password', $this->password);
         $xw->endElement();
         $xw->startElement('text');
         $xw->writeRaw($this->raw_text);
         $xw->endElement();
         $xw->endElement();
         $message = iconv("utf-8", "big5", $xw->outputMemory(true));
         //send message to CKIP server
         set_time_limit(60);
         $protocol = getprotobyname("tcp");
         $socket = socket_create(AF_INET, SOCK_STREAM, $protocol);
         socket_connect($socket, $this->server_ip, $this->server_port);
         socket_write($socket, $message);
         $this->return_text = iconv("big5", "utf-8", socket_read($socket, strlen($message) * 3));
         socket_shutdown($socket);
         socket_close($socket);
     }
     return $this->return_text;
 }
开发者ID:spicyscap,项目名称:CKIPClient-PHP,代码行数:40,代码来源:CKIPClient.php

示例6: unlock

 /**
  *
  *  @unlock
  *
  *  @description
  *      - unlock the port
  *
  *  @parameters
  *      - 
  *
  *  @return
  *      -  
  *              
  */
 public function unlock()
 {
     //free
     @socket_shutdown($this->_Sock, 2);
     @socket_close($this->_Sock);
     debug("unlock() :: Try to reset the port! [{$this->_Port}] ");
 }
开发者ID:bayugyug,项目名称:LDAP-Api,代码行数:21,代码来源:com.utils.portlocker.class.php

示例7: init

 public function init()
 {
     if (!($sock = socket_create(AF_INET, SOCK_STREAM, 0))) {
         $errorcode = socket_last_error();
         $errormsg = socket_strerror($errorcode);
         die("Couldn't create socket: [{$errorcode}] {$errormsg} \n");
     }
     echo "Socket created \n";
     //Connect socket to remote server
     if (!socket_connect($sock, self::ADDRESS, self::PORT)) {
         $errorcode = socket_last_error();
         $errormsg = socket_strerror($errorcode);
         die("Could not connect: [{$errorcode}] {$errormsg} \n");
     }
     echo "Connection established \n";
     $message = json_encode(['message' => 'Alright!']);
     //Send the message to the server
     if (!socket_send($sock, $message, strlen($message), 0)) {
         $errorcode = socket_last_error();
         $errormsg = socket_strerror($errorcode);
         die("Could not send data: [{$errorcode}] {$errormsg} \n");
     }
     echo "Message send successfully \n";
     //Now receive reply from server
     if (socket_recv($sock, $buf, 2045, MSG_WAITALL) === FALSE) {
         $errorcode = socket_last_error();
         $errormsg = socket_strerror($errorcode);
         die("Could not receive data: [{$errorcode}] {$errormsg} \n");
     }
     //print the received message
     socket_shutdown($sock);
     return $buf;
 }
开发者ID:LucasMaliszewski,项目名称:SimpleAi,代码行数:33,代码来源:Listen.php

示例8: close

 public function close() {
   if ($this->connected) {
     socket_shutdown($this->socket);
     socket_close($this->socket);
     $this->socket = null;
   }
 }
开发者ID:sosedoff,项目名称:debugclient-php,代码行数:7,代码来源:DebugClient.php

示例9: refreshDiscordId

 private function refreshDiscordId($discordId)
 {
     $options = XenForo_Application::get('options');
     if ($options->botSocket === '') {
         return;
     }
     XenForo_Error::debug("Refreshing user {$discordId}");
     $so = socket_create(AF_UNIX, SOCK_DGRAM, 0);
     if ($so === false) {
         $msg = socket_strerror(socket_last_error());
         $error = "Bot socket create failed: {$msg}";
         throw new Exception($error);
     }
     $res = socket_connect($so, $options->botSocket);
     if ($res === false) {
         $msg = socket_strerror(socket_last_error());
         $error = "Bot socket connect failed: {$msg}";
         throw new Exception($error);
     }
     $payload = json_encode(array('action' => 'refresh', 'user_id' => $discordId));
     $res = socket_write($so, $payload);
     socket_shutdown($so);
     socket_close($so);
     if ($res === false) {
         $error = "Bot socket send failed";
         throw new Exception($error);
     } else {
         if ($res < strlen($payload)) {
             // This will probably never happen.
             $error = "Bot socket did not send all data";
             throw new Exception($error);
         }
     }
 }
开发者ID:Hornwitser,项目名称:DiscordAuthorizer,代码行数:34,代码来源:User.php

示例10: disconnect

 /**
  * @return bool
  */
 public function disconnect()
 {
     if ($this->connection === null) {
         return true;
     }
     return socket_shutdown($this->connection);
 }
开发者ID:zhgit,项目名称:php-cassandra,代码行数:10,代码来源:Connection.php

示例11: CloseClient

 public static function CloseClient($Client)
 {
     if ($Client != Null) {
         @socket_shutdown($Client, 2);
         //Schließe den Socket in beiden Richtungen
         socket_close($Client);
     }
 }
开发者ID:gOOvER,项目名称:EasySCP,代码行数:8,代码来源:SocketHandler.php

示例12: disconnect

 public function disconnect()
 {
     if (!$this->usingProxy) {
         socket_shutdown($this->resSocket);
     } else {
         unset($this->proxyObject);
     }
 }
开发者ID:Karth123,项目名称:Club-Penguin-Programs,代码行数:8,代码来源:ClientBase.php

示例13: close

 public function close()
 {
     if (is_resource($this->socket)) {
         @socket_shutdown($this->socket, 2);
         @socket_close($this->socket);
     }
     $this->disconnected = true;
 }
开发者ID:rburchell,项目名称:air,代码行数:8,代码来源:SocketBase.php

示例14: disconnect

 public function disconnect()
 {
     if (@socket_shutdown($this->sock, 2) == FALSE) {
         return aff_error(socket_strerror(socket_last_error()));
     }
     socket_close($this->sock);
     aff_ok("Closing connection client " . $this->id . " on server : " . $this->host . ":" . $this->port . " succeed.");
 }
开发者ID:nott0ny,项目名称:zappy2010,代码行数:8,代码来源:class_communication.php

示例15: close

 public function close()
 {
     if (is_resource($this->socket)) {
         @socket_shutdown($this->socket, 2);
         @socket_close($this->socket);
     }
     $this->socket = (int) $this->socket;
 }
开发者ID:wrtcoder,项目名称:mini_isp,代码行数:8,代码来源:socket.php


注:本文中的socket_shutdown函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。