function encode($msgType, $timeStamp, $body) {return "\xFF\xFF".pack('CNn', $msgType, $timeStamp, strlen($body)).$body;}$connection->send(encode(1, time(), 'reqLoginAlarm;user=xxx;key=xxx;type=xxx'));
详情参考: 请教使用socket做为客户端和北向接口对接,请教如何打包数据发送。-workerman社区