php fsockopen 并发,该如何处理

WBOY
Release: 2016-06-13 10:42:50
Original
860 people have browsed it

php fsockopen 并发
求教 fsockopen 并发。
我想发邮件 不知道 fsockopen 这个怎么并发邮件

------解决方案--------------------
你可以ajax循环执行发送邮件,也可以用下面两个方法(西面代码是大致思路):

PHP code
if (isset($_GET['act']) && $_GET['act'] == 'sendMail') {    sendEmail();// 发送邮件操作}function fSockGet($url, $timeout = 3){    $info = parse_url($url);    extract($info);    $query = isset($query) ? trim($query) : '';    $path = isset($path) ? trim($path) : '';    $fp = fsockopen($host, 80, $errno, $errstr, $timeout);    if (!$fp) {        exit("$errstr ($errno)<br>\n");    }    $write = fwrite($fp, "GET {$path}?{$query} HTTP/1.0\r\nHost: {$host}\r\n\r\n");//    while (!feof($fp)) {//        echo fread($fp, 4096);//    }}$url = "http://mydir.com/index.php?act=sendMail";$emailList = array(...);foreach ($emailList as $email) {    fSockGet($url);}<div class="clear">
                 
              
              
        
            </div>
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!