使用php的smpp绑定问题

问题描述

<?php


define('DEBUGLOG',file_get_contents('debuglog.ini') ? true : false);
include_once 'vendor/autoload.php';
include_once 'accounts.php';
shuffle($accounts);
$aCnt = count($accounts);
$aI = 0;



    $loop = React\EventLoop\Factory::create();
    $connector = new React\Socket\Connector($loop);

    foreach($rows as $row) {
        $account = $accounts[$aI];  // this smpp account 
        $aI ++;
        if($aI >= $aCnt) $aI = 0;
        $connector->connect($account[0])->then(function (React\Socket\ConnectionInterface $connection) use ($db,$row,$account) {
            $seq = 0;
            $connection->on('error',function($error) use ($connection) {
                echo "error:$error\n";
                $connection->end();
            });
            $connection->once('data',function ($chunk) use ($connection,$db,$seq,$account) {
                $connection->on('data',function($chunk) use ($connection,$row) {
                    $date = date('Y-m-d H:i:s');
                    $db->query("UPDATE senders SET status = 1,sendtime = '$date' WHERE id={$row['id']}");
                    $connection->end();
                });
                $messageinv = iconv("UTF-8","UCS-2BE",trim($row['message']));
                $size = strlen($messageinv) + 20;
                $sourceaddr = rand(00000,99999);
                if($size < 160) {
                    $data = makeSend($sourceaddr,$row['phone_number'],$messageinv);
                    $pdu = makePdu(4,$data,++$seq);
                    $connection->write($pdu);
                } else {
                    $sar_msg_ref_num =  rand(1,255);
                    $sar_total_segments = ceil(strlen($messageinv) / 160);

                    for($sar_segment_seqnum = 1; $sar_segment_seqnum <= $sar_total_segments; $sar_segment_seqnum ++) {
                        $part = substr($messageinv,160);
                        $messageinv = substr($messageinv,160);

                        $optional  = pack('nnn',0x020C,2,$sar_msg_ref_num);
                        $optional .= pack('nnc',0x020E,1,$sar_total_segments);
                        $optional .= pack('nnc',0x020F,$sar_segment_seqnum);

                        $data = makeSend($sourceaddr,$part,$optional);
                        $pdu = makePdu(4,++$seq);
                        $connection->write($pdu);
                    }
                }
                if(DEBUGLOG) file_put_contents('/home/smppbot/log/debug.log',date('Y-m-d H:i:s ').implode(' ',$account)."\n",FILE_APPEND);
            });
            $data = makeLogin($account[1],$account[2]);
            $pdu = makePdu(2,++$seq);
            $connection->write($pdu);
        });
    }
    $loop->run();
}

这是我的代码.. 在centos7中使用sysctl 但有一点问题。

此代码为1绑定,其中1个数字发送给smpp .. 连接100bind发送100number。 运行并退出循环... 这种异常 但我想发送许多绑定1 我该怎么做?.. 等待很多建议...

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...