我需要在PHP中设置持久套接字连接,但不确定如何实现这一点。目前,当我发送短信时,我a)打开套接字连接b)发送消息(通过SMS / SMPP)和c)关闭套接字连接
但是我不需要一直打开和关闭连接。相反,我需要
- 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.
更新:想知道是否有人使用以下内容实现了上述目标:https://github.com/shaneharter/PHP-Daemon
答案 0 :(得分:1)
函数pfsockopen似乎具有您正在寻找的功能。看看这个问题 - PHP pfsockopen in a session。
===
对您的实施进行个人观察。我假设PHP代码将由传入请求触发,并且所有其他时间,SMPP客户端将处于非活动状态。这可能不太适合SMPP,原因如下: