📌  相关文章
📜  wordpress 与 socket.oi 站点:stackoverflow.com - 任何代码示例

📅  最后修改于: 2022-03-11 15:00:55.380000             🧑  作者: Mango

代码示例1
function sio_message($message, $data) {
    $socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
    $result = socket_connect($socket, '127.0.0.1', 8080);
    if(!$result) {
        die('cannot connect '.socket_strerror(socket_last_error()).PHP_EOL);
    }
    $bytes = socket_write($socket, json_encode(Array("msg" => $message, "data" => $data)));
    socket_close($socket);
}