2016-06-08 5 views
0

SMSC에 영구 연결이 설정되면 다음 코드를 계속 실행하는 방법. 여기서 setRecvTimeout (60000)의 명확한 의미는 무엇입니까?Smpp는 PHP에서 SMS를 수신합니다.

<?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(); 

} 
?> 

답변

0

간단히 말해서 내부 시간 제한을 60 초로 설정한다는 의미입니다. 따라서 60 초 후에 아무 것도 수신하지 않으면 연결이 끊어 졌다는 의미입니다.

그건 시간 초과의 일반적인 원칙입니다.

+0

누군가이 코드를 계속 실행하는 방법을 알려주십시오. –

+0

이미 무한 루프 ('for')에 있지 않습니까? –

+0

이 코드를 계속 실행하려면 시간 제한을 설정해야합니까? –