【发布时间】:2016-06-08 05:19:15
【问题描述】:
当与 SMSC 建立持久连接时,如何连续运行以下代码。以及这里 setRecvTimeout(60000) 的明确含义是什么。
<?php //Receive sms
require_once 'smppclient.class.php';
require_once 'sockettransport.class.php';
// Construct transport and client
$transport = new SocketTransport(array('smpp.provider.com'),3600);
$transport->setRecvTimeout(60000); // for this example wait up to 60 seconds for data
for(;;){
$smpp = new SmppClient($transport);
// Activate binary hex-output of server interaction
$smpp->debug = true;
$transport->debug = true;
// Open the connection
$transport->open();
$smpp->bindReceiver("USERNAME","PASSWORD");
// Read SMS and output
$sms = $smpp->readSMS();
$read = $sms -> message;// reads the message
echo $read."\n";
$phone = $sms -> source-> value; //gets the phone number
echo $phone."\n";
echo "SMS:\n";
//var_dump($sms);
// Close connection
$smpp->close();
}
?>
【问题讨论】: