I need to set up a persistent socket connection in PHP and not sure how to achieve this. Currently when I send an SMS message I a) open a socket connection b) send a message (via SMS/SMPP) and c) close the socket connection
however I need to not open and close the connection all the time. Rather, I require
- 2 persistent connections that maintains connectivity to an SMSC (SMS centre) and reconnects when a timeout occurs.
- One persistent connection for reading SMS and one for sending SMS.
- Automatic restart/recovery (i.e. when memory issues arise)
- Automatic looping to act as listener for incoming events such as receiving incoming delivery receipts and sms messages, as well as 'ping' (enquire link) to keep SMPP connection alive.
UPDATE: Was wondering if anyone had achieved the above using the following: https://github.com/shaneharter/PHP-Daemon
Function pfsockopen seems to have capabilities you are looking for. Check out this question - PHP pfsockopen in a session .
===
A personal observation on your implementation. I am assuming that PHP code will be triggered by an incoming request and all other times, SMPP client will be inactive. This may not be quite suitable for SMPP for few reasons:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.