php谨防超时我用CURl,3秒超时示例!

jackxiang 2008-10-28 12:08 | |
        private function setQueue($data,$q="MultiMsgSend") {
            $str_url = 'http://10.210.71.85/send_message.php';
            $data = "queuename={$q}&queuedata={$data}";
      
            $ch_curl = curl_init ();
            curl_setopt ( $ch_curl, CURLOPT_TIMEOUT, 3 );
            curl_setopt ( $ch_curl, CURLOPT_HEADER, false );

            curl_setopt($ch_curl,CURLOPT_POST,TRUE);
            curl_setopt($ch_curl,CURLOPT_POSTFIELDS,$data);
            curl_setopt ( $ch_curl, CURLOPT_RETURNTRANSFER, true );
            curl_setopt ( $ch_curl, CURLOPT_URL, $str_url );
      
            $str_return = curl_exec ( $ch_curl );
      
            if ($str_return === false)
            {
                $this->setErrorNo(11);
                return false;
            }
            curl_close ( $ch_curl );
            return true;
        }

作者:jackxiang@向东博客 专注WEB应用 构架之美 --- 构架之美,在于尽态极妍 | 应用之美,在于药到病除
地址:https://jackxiang.com/post/1331/
版权所有。转载时必须以链接形式注明作者和原始出处及本声明!


最后编辑: jackxiang 编辑于2008-10-28 12:09
评论列表
发表评论

昵称

网址

电邮

打开HTML 打开UBB 打开表情 隐藏 记住我 [登入] [注册]