I have a situation where I need to update one browser window based on input from the other. Right now I'm using WebSockets and it's working great.
Now I want to send data to the WebSocket using PHP instead of the browser (so instead of ws://, use PHP code). In other words, I want to simulate the WebSocket.send() call using PHP instead of JavaScript.
I have the following code which doesn't seem to work (the onmessage is not being called):
if ( 
        function_exists('socket_create') AND
        $sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP) AND
        $sock_data = socket_connect($sock, "127.0.0.1", 12345)
    ) {  
        $msg = "hello world";
        $sock_data = socket_set_option($sock, SOL_SOCKET, SO_BROADCAST, 1); //Set 
        $sock_data = socket_write($sock, $msg, strlen($msg)); //Send data
        socket_close($sock); //Close socket
    } 
 
     
     
     
    