I have an external source from which I receive streaming data. It is from an outside domain so I can't access it using ajax. What I want to do is use my own server as a proxy to output that data to ajax.
My first idea was to simply read the data from the external file, then output it back out using echo and flush statements. Unfortunately my webserver buffers the output so the data isn't streamed live but instead in blocks.
I heard I could use a "socket server" to do this... I've never done this before so I'm going to outline my test idea and ask if I am taking the right approach
I create a file startserver.php
this file creates the socket server on ip address 127.0.0.1 port 9000
I use ajax to call startserver.php this starts some while(true) loop that basically checks for incoming client connections.
So theoretically this socket server should be able to send data... which is easy using socket_write.
but how do I read the data back? and furthermore how do I send data to the server?
I tried making a test file, where the server simply returns the input back.
This is how I tested it :
In my browser I got to : localhost/startserver.php ...
let that run, then open a new tab and type in localhost:9000/test
and nothing happens, it doesn't spit anything back out or anything.
How exactly am i supposed to access the server, read/write from it?
Thanks