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


PHP socket_set_blocking函数代码示例

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


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

示例1: sms_custom_handle

function sms_custom_handle($sms_datetime, $sms_sender, $custom_keyword, $custom_param = '')
{
    global $datetime_now;
    $ok = false;
    $db_query = "SELECT custom_url FROM " . _DB_PREF_ . "_featureCustom WHERE custom_keyword='{$custom_keyword}'";
    $db_result = dba_query($db_query);
    $db_row = dba_fetch_array($db_result);
    $custom_url = $db_row['custom_url'];
    $sms_datetime = core_display_datetime($sms_datetime);
    $custom_url = str_replace("{SMSDATETIME}", urlencode($sms_datetime), $custom_url);
    $custom_url = str_replace("{SMSSENDER}", urlencode($sms_sender), $custom_url);
    $custom_url = str_replace("{CUSTOMKEYWORD}", urlencode($custom_keyword), $custom_url);
    $custom_url = str_replace("{CUSTOMPARAM}", urlencode($custom_param), $custom_url);
    $url = parse_url($custom_url);
    if (!$url['port']) {
        $url['port'] = 80;
    }
    // fixme anton -deprecated when using PHP5
    //$connection = fsockopen($url['host'],$url['port'],&$error_number,&$error_description,60);
    $connection = fsockopen($url['host'], $url['port'], $error_number, $error_description, 60);
    if ($connection) {
        socket_set_blocking($connection, false);
        fputs($connection, "GET {$custom_url} HTTP/1.0\r\n\r\n");
        $db_query = "\n\t    INSERT INTO " . _DB_PREF_ . "_featureCustom_log\n\t    (sms_sender,custom_log_datetime,custom_log_keyword,custom_log_url) \n\t    VALUES\n\t    ('{$sms_sender}','{$datetime_now}','{$custom_keyword}','{$custom_url}')\n\t";
        if ($new_id = @dba_insert_id($db_query)) {
            $ok = true;
        }
    }
    return $ok;
}
开发者ID:080400107073,项目名称:playSMS,代码行数:30,代码来源:fn.php

示例2: IMAP_connect

function IMAP_connect($s, $p = '143')
{
    global $_IMAP_KEY;
    $c = fsockopen($s, $p);
    socket_set_blocking($c, FALSE);
    return array('conn' => $c, 'key' => $_IMAP_KEY++, 'callbacks' => array(), 'cbdata' => array(), 'state' => 'UNAUTHENTICATED');
}
开发者ID:nbtscommunity,项目名称:phpfnlib,代码行数:7,代码来源:imap.php

示例3: Connect2ICQServer

 function Connect2ICQServer()
 {
     $this->fp = @fsockopen($this->ICQServer, 80, $errno, $errstr, 90);
     if (!$this->fp) {
         return;
     }
     socket_set_blocking($this->fp, 1);
 }
开发者ID:BackupTheBerlios,项目名称:alumni-online-svn,代码行数:8,代码来源:ICQ_Status.class.php

示例4: openSocket

 function openSocket($server, $port)
 {
     if ($this->activeSocket = fsockopen($server, $port)) {
         socket_set_blocking($this->activeSocket, 0);
         socket_set_timeout($this->activeSocket, 31536000);
         return true;
     }
     return false;
 }
开发者ID:GadgetStrike,项目名称:Zeus,代码行数:9,代码来源:jabberclass.php

示例5: multiHTTP

function multiHTTP($urlArr)
{
    $sockets = array();
    $urlInfo = array();
    $retDone = array();
    $retData = array();
    $errno = array();
    $errstr = array();
    $user_agent = "Castcloud crawler; +https://github.com/castcloud/castcloud (PHP " . phpversion() . ")";
    for ($x = 0; $x < count($urlArr); $x++) {
        try {
            $urlInfo[$x] = parse_url($urlArr[$x]);
            $urlInfo[$x]["port"] = array_key_exists("port", $urlInfo[$x]) ? $urlInfo[$x]["port"] : 80;
            $urlInfo[$x]["path"] = array_key_exists("path", $urlInfo[$x]) ? $urlInfo[$x]["path"] : "/";
            $sockets[$x] = fsockopen($urlInfo[$x]["host"], $urlInfo[$x]["port"], $errno[$x], $errstr[$x], 1);
            if ($sockets[$x]) {
                socket_set_blocking($sockets[$x], FALSE);
                $query = array_key_exists("query", $urlInfo[$x]) ? "?" . $urlInfo[$x]["query"] : "";
                $req = "GET " . $urlInfo[$x]["path"] . "{$query} HTTP/1.0\r\nHost: " . $urlInfo[$x]["host"] . "\r\nUser-Agent: " . $user_agent . "\r\n";
                if (array_key_exists("etag", $GLOBALS['casts'][$x])) {
                    $req .= "If-None-Match: " . $GLOBALS['casts'][$x]['etag'] . "\r\n";
                }
                $req .= "\r\n";
                fputs($sockets[$x], $req);
            }
        } catch (Exception $e) {
            echo $urlArr[$x] . " failed :(\n";
        }
    }
    echo "Done opening " . sizeof($sockets) . " sockets!\n\n";
    $done = false;
    while (!$done) {
        for ($x = 0; $x < count($urlArr); $x++) {
            if ($sockets[$x]) {
                if (!feof($sockets[$x])) {
                    if (array_key_exists($x, $retData)) {
                        $retData[$x] .= fgets($sockets[$x], 512);
                    } else {
                        $retData[$x] = fgets($sockets[$x], 512);
                    }
                } else {
                    if (!array_key_exists($x, $retData)) {
                        $retData[$x] = null;
                    }
                    $retDone[$x] = 1;
                }
            } else {
                $retData[$x] = null;
                $retDone[$x] = 1;
            }
        }
        usleep(1);
        $done = array_sum($retDone) == count($urlArr);
    }
    return $retData;
}
开发者ID:Castcloud,项目名称:castcloud-php-server,代码行数:56,代码来源:crawler.php

示例6: connect

 /**
  * Connect to the stratum server.
  * @param string $host
  * @param string $port
  * @return array stdResult
  */
 public function connect($host, $port = "3333")
 {
     $connect_string = "tcp://{$host}:{$port}";
     if (($this->conn = stream_socket_client($connect_string, $errno, $errstr)) === false) {
         return array(false, "Unable to connect to {$host}:{$port} [{$errstr}]");
     }
     $this->connected = true;
     socket_set_blocking($this->conn, false);
     return array(true, "Connected to {$host}:{$port}");
 }
开发者ID:KaSt,项目名称:cryptocoin_scrypt_stratum,代码行数:16,代码来源:StratumServer.php

示例7: gw_send_sms

function gw_send_sms($mobile_sender, $sms_to, $sms_msg, $gp_code = "", $uid = "", $smslog_id = "", $flash = false)
{
    //error_log("gw_send_sms: $mobile_sender, $sms_to, $sms_msg \n");
    global $kannel_param;
    global $gateway_number;
    $ok = false;
    if ($gateway_number) {
        $sms_from = $gateway_number;
    } else {
        $sms_from = $mobile_sender;
    }
    if ($flash) {
        $sms_type = KANNEL_SMSTYPE_FLASH;
    } else {
        $sms_type = KANNEL_SMSTYPE_TEXT;
    }
    // we can give kannel a callback url where it
    // will give us the dlr of the sms we're sending
    // (%d is where kannel will put the status, the rest of
    // the params are for us)
    //
    $dlr_url = urlencode($kannel_param['playsms_web'] . "/plugin/gateway/kannel/dlr.php?dlr=%d&smslog_id={$smslog_id}&uid={$uid}");
    $dlr_mask = "31";
    // now build the url to send
    // this sms to kannel
    //
    $URL = "/cgi-bin/sendsms?";
    $URL .= "username=" . urlencode($kannel_param['username']);
    $URL .= "&password=" . urlencode($kannel_param['password']);
    $URL .= "&from=" . urlencode($sms_from) . "&to=" . urlencode($sms_to) . "&text=" . urlencode($sms_msg);
    $URL .= "&mclass={$sms_type}";
    $URL .= "&dlr-mask={$dlr_mask}&dlr-url={$dlr_url}";
    // TODO: replace the fsockopen stuff with php's file_get_contents()
    // but for some reason it doesn't seem to work with kannel!
    //
    //$server= 'http://' . $kannel_param['bearerbox_host'] . ':' . $kannel_param['sendsms_port'];
    //$URL= $server . $URL;
    //$response= file_get_contents($URL);
    //if ($response == KANNEL_MSG_ACCEPTED) {
    //    $ok = true;
    //}
    $connection = fsockopen($kannel_param['bearerbox_host'], $kannel_param['sendsms_port'], $error_number, $error_description, 60);
    if ($connection) {
        socket_set_blocking($connection, false);
        fputs($connection, "GET {$URL} HTTP/1.0\r\n\r\n");
        while (!feof($connection)) {
            $myline = fgets($connection, 128);
            if ($myline == KANNEL_MSG_ACCEPTED) {
                $ok = true;
            }
        }
    }
    fclose($connection);
    return $ok;
}
开发者ID:laiello,项目名称:ya-playsms,代码行数:55,代码来源:fn.php

示例8: socket_open

 function socket_open($hostname, $port, $timeout)
 {
     if ($this->socket = @fsockopen($hostname, $port, $errno, $errstr, $timeout)) {
         socket_set_blocking($this->socket, 0);
         socket_set_timeout($this->socket, 31536000);
         return true;
     } else {
         $this->error = "{$errstr} (#{$errno}, " . __FILE__ . ", " . __LINE__ . ")";
         return false;
     }
 }
开发者ID:nishant,项目名称:php-jabber,代码行数:11,代码来源:class_ConnectionSocket.php

示例9: socket_open

 function socket_open($hostname, $port, $timeout)
 {
     if ($this->socket = @fsockopen($hostname, $port, $errno, $errstr, $timeout)) {
         socket_set_blocking($this->socket, 0);
         socket_set_timeout($this->socket, 60);
         return true;
     } else {
         $this->error = "{$errstr} (#{$errno})";
         return false;
     }
 }
开发者ID:alphashuro,项目名称:audeprac,代码行数:11,代码来源:class_ConnectionSocket.php

示例10: connect

 private function connect()
 {
     if (!isset($this->jid)) {
         return $this->connection = false;
     }
     if (!isset($this->idle)) {
         $this->idle = true;
     }
     if (!isset($this->resource)) {
         $this->resource = 'caldav' . getmypid();
     }
     if (!preg_match('/^\\//', $this->resource)) {
         $this->resource = '/' . $this->resource;
     }
     $temp = explode('@', $this->jid);
     $this->username = $temp[0];
     if (!isset($this->server)) {
         $this->server = $temp[1];
     }
     $r = dns_get_record("_xmpp-client._tcp." . $this->server, DNS_SRV);
     if (0 < count($r)) {
         $this->original_server = $this->server;
         $this->server = $r[0]['target'];
         $this->original_port = $this->port;
         $this->port = $r[0]['port'];
     }
     if (!isset($this->port)) {
         $this->port = 5222;
     }
     if ('ssl' == $this->tls || !isset($this->tls) && 5223 == $this->port) {
         $url = 'ssl://' . $this->server;
     } elseif ('tls' == $this->tls || !isset($this->tls) && 5222 == $this->port) {
         $url = 'tcp://' . $this->server;
     } else {
         $url = 'tcp://' . $this->server;
     }
     if (isset($this->original_server)) {
         $this->server = $this->original_server;
     }
     $this->connection = stream_socket_client($url . ':' . $this->port, $errno, $errstring, 10, STREAM_CLIENT_ASYNC_CONNECT);
     if (false === $this->connection) {
         if ($errno != 0) {
             $log = $errstring;
         }
         return false;
     }
     $this->initializeQueue();
     socket_set_blocking($this->connection, false);
     return true;
 }
开发者ID:derekyu1437,项目名称:davical,代码行数:50,代码来源:pubsub.php

示例11: connect

 function connect($server, $port = 110)
 {
     //  Opens a socket to the specified server. Unless overridden,
     //  port defaults to 110. Returns true on success, false on fail
     // If MAILSERVER is set, override $server with it's value
     if (!empty($this->MAILSERVER)) {
         $server = $this->MAILSERVER;
     }
     if (empty($server)) {
         $this->ERROR = "POP3 connect:" . ' ' . "No server specified";
         unset($this->FP);
         return false;
     }
     $fp = fsockopen("{$server}", $port, $errno, $errstr);
     if (!$fp) {
         $this->ERROR = "POP3 connect:" . ' ' . "Error " . "[{$errno}] [{$errstr}]";
         unset($this->FP);
         return false;
     }
     socket_set_blocking($fp, -1);
     $this->update_timer();
     $reply = fgets($fp, $this->BUFFER);
     $reply = $this->strip_clf($reply);
     if ($this->DEBUG) {
         error_log("POP3 SEND [connect: {$server}] GOT [{$reply}]", 0);
     }
     if (!$this->is_ok($reply)) {
         $this->ERROR = "POP3 connect:" . ' ' . "Error " . "[{$reply}]";
         unset($this->FP);
         return false;
     }
     $this->FP = $fp;
     $this->BANNER = $this->parse_banner($reply);
     //		if(get_settings('shot_rfc_check')) {
     $this->RFC1939 = $this->noop();
     if ($this->RFC1939) {
         $this->ERROR = "POP3: premature NOOP OK, NOT an RFC 1939 Compliant server";
         $this->quit();
         return false;
     } else {
         return true;
     }
     //		} else {
     //			return true;
     //		}
 }
开发者ID:naao,项目名称:d3diary,代码行数:46,代码来源:post_pop3.php

示例12: jab_connect

function jab_connect($server, $port)
{
    global $errfile;
    if (!isset($errfile)) {
        $errfile = "/tmp/php_error.log";
    }
    $fd = fsockopen($server, $port, $errno, $errstr, 30);
    if (!$fd) {
        $errmsg = "Error: {$errno} - {$errstr}\n";
        error_log($errmsg, 3, $errfile);
        return FALSE;
    }
    $fdp = socket_set_blocking($fd, 0);
    $stream = "<stream:stream to='{$server}' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams'>";
    fputs($fd, $stream);
    return $fd;
}
开发者ID:erdincay,项目名称:kamailio_ims,代码行数:17,代码来源:libjab.php

示例13: sendViaFileHandle

 private function sendViaFileHandle($message)
 {
     try {
         // Open the UDP socket to send the data.
         $socket = @fsockopen("udp://" . $this->destHost, $this->destPort);
         if (!$socket) {
             // TODO: Log.warn: "Socket failed to open"
             // TODO: Use a finally block instead (PHP 5.5).
             throw new Exception("Cancelling send.");
         }
         @socket_set_blocking($socket, FALSE);
         // Send the header.
         $header = $message->getHeader();
         $bytesWritten = @fwrite($socket, $header);
         if ($bytesWritten < strlen($header)) {
             // TODO: Log.warn "Only wrote $bytesWritten bytes of the header."
             // TODO: Use a finally block instead (PHP 5.5).
             throw new Exception("Cancelling send.");
         }
         // Send the payload.
         $payload = $message->getPayload();
         $bytesWritten = @fwrite($socket, $payload);
         if ($bytesWritten < strlen($payload)) {
             // TODO: Log.warn "Only wrote $bytesWritten bytes of the payload."
             // TODO: Use a finally block instead (PHP 5.5).
             throw new Exception("Cancelling send.");
         }
         // Close the socket.
         @fclose($socket);
         // dereference the handles.
         $socket = null;
         $header = null;
         $payload = null;
     } catch (Exception $e) {
         // TODO: Move this to a finally block (PHP 5.5).
         if ($socket) {
             try {
                 @fclose($socket);
             } catch (Exception $e2) {
             }
         }
         $socket = null;
         return;
     }
 }
开发者ID:jonnyanyc,项目名称:gmetric-php,代码行数:45,代码来源:Gmetric.php

示例14: send

 /**
  * 데이타 전송함수
  *
  * @param string $mode : POST, GET 중 하나를 입력한다.
  * @return string
  */
 function send($mode = "GET")
 {
     // 웹서버에 접속한다.
     $fp = fsockopen($this->host, $this->port, $errno, $errstr, 10);
     if (!$fp) {
         return $this->setError($this->host . "로의 접속에 실패했습니다.");
     }
     // GET, POST 방식에 따라 헤더를 다르게 구성한다.
     if (strtoupper($mode) == "POST") {
         $this->query = $this->postMethod();
     } else {
         $this->query = $this->getMethod();
     }
     fputs($fp, $this->query);
     socket_set_blocking($fp, FALSE);
     $this->handles[] = $fp;
     $this->yuser[$fp] = $this->_user;
     return $fp;
 }
开发者ID:jin255ff,项目名称:company_website,代码行数:25,代码来源:dm.php

示例15: gw_send_sms

function gw_send_sms($mobile_sender, $sms_sender, $sms_to, $sms_msg, $gp_code = "", $uid = "", $smslog_id = "", $flash = false)
{
    global $kannel_param;
    global $gateway_number;
    $ok = false;
    if ($gateway_number) {
        $sms_from = $gateway_number;
    } else {
        $sms_from = $mobile_sender;
    }
    if ($sms_sender) {
        $sms_msg = $sms_msg . $sms_sender;
    }
    // set failed first
    $p_status = 2;
    setsmsdeliverystatus($smslog_id, $uid, $p_status);
    $sms_type = 2;
    // text
    if ($flash) {
        $sms_type = 1;
        //flash
    }
    $URL = "/cgi-bin/sendsms?username=" . urlencode($kannel_param['username']) . "&password=" . urlencode($kannel_param['password']);
    $URL .= "&from=" . urlencode($sms_from) . "&to=" . urlencode($sms_to) . "&text=" . urlencode($sms_msg);
    $URL .= "&dlr-mask=31&dlr-url=" . urlencode($kannel_param['phpgwsms_web'] . "/plugin/gateway/kannel/dlr.php?type=%d&slid={$smslog_id}&uid={$uid}");
    $URL .= "&mclass={$sms_type}";
    $connection = fsockopen($kannel_param['bearerbox_host'], $kannel_param['sendsms_port'], &$error_number, &$error_description, 60);
    if ($connection) {
        socket_set_blocking($connection, false);
        fputs($connection, "GET {$URL} HTTP/1.0\r\n\r\n");
        while (!feof($connection)) {
            $myline = fgets($connection, 128);
            if ($myline == "Sent.") {
                $ok = true;
                // set pending
                $p_status = 0;
                setsmsdeliverystatus($smslog_id, $uid, $p_status);
            }
        }
    }
    fclose($connection);
    return $ok;
}
开发者ID:HaakonME,项目名称:porticoestate,代码行数:43,代码来源:fn.php


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