kvorak Posted July 31, 2009 Share Posted July 31, 2009 Hey all, FYI, this is my first post to this group, so be gentle . I should point out that I come from a native code background and have recently been asked by my employer to try to write a web-application. This being a totally separate discipline of its own, I'm kinda treading water in the sea of information here. With that said, I have a few questions that have come up during all the reading I have been doing; mostly statements that I don't understand or questions that I cannot find definitive answers to. So if you would indulge my curiosity... here goes: My boss is asking if there is a way to write an application, probably using PHP, that will open a connection to a remote server and accept streaming data from it, and then pass that data to a (AJAX enabled?) script that is running client side so that new information gathered by the remote server can be 'streamed' directly to the client display. My initial answer was that it would be easy to stream the data in using stream_socket_client or some such equivalent for the sake of using that data from within the PHP script. But not knowing a whole lot about network architecture (except that is a REST arch where there really isn't such a thing as a persistent connection between server and client) I'm not sure how to go about getting that data back to the client without writing a while loop in the JavaScript. My other question was, 'how easy is it write to an RSS feed using PHP?'. Am I correct that it would really be as simple as opening a file ($file = popen('path/to/rss.xml', ab)) and then appending the new entries to the file and closing it again? Pardon my jadedness but that seems to simple. Thanks so much for your patience. Jason Hamilton Quote Link to comment https://forums.phpfreaks.com/topic/168319-how-to-stream-data-not-media-to-a-client-web-page/ Share on other sites More sharing options...
.josh Posted July 31, 2009 Share Posted July 31, 2009 1) what exactly do you mean by "streaming"? Do you mean like with video/audio where it plays as it downloads, or do you mean it in the "data being updated live" context? Assuming it is the latter, all you would do is setup the basic ajax functions, and then just create a function that triggers the ajax functions and also calls itself recursively using settimeout. 2) yes. Quote Link to comment https://forums.phpfreaks.com/topic/168319-how-to-stream-data-not-media-to-a-client-web-page/#findComment-887883 Share on other sites More sharing options...
kvorak Posted July 31, 2009 Author Share Posted July 31, 2009 Thanks Crayon Violent. In essence, what you're talking about is just polling the stream, right? Like I said, I'm a little new to web-programming, could you (or anyone else) point me to a good place to see that process? Or even just post the code here assuming it isn't terribly long? Remember, I don't know enough AJAX for anything to be a 'basic Ajax function'. Quote Link to comment https://forums.phpfreaks.com/topic/168319-how-to-stream-data-not-media-to-a-client-web-page/#findComment-887884 Share on other sites More sharing options...
.josh Posted July 31, 2009 Share Posted July 31, 2009 by "basic" I mean there's really not much to it. If you google any ajax tutorial they will show you pretty much the same thing. Basically it boils down to instantiating an object, but the syntax is browser dependent. Quote Link to comment https://forums.phpfreaks.com/topic/168319-how-to-stream-data-not-media-to-a-client-web-page/#findComment-887893 Share on other sites More sharing options...
kvorak Posted July 31, 2009 Author Share Posted July 31, 2009 Thanks, I did like you said and google'd it; you're right, that doesn't look hard. Just to clarify, this would indicate that there is no way for a PHP script to 'push' data to a client without the client requesting it. I would assume that was the case with a REST system, but I just wanted to verify that.... Quote Link to comment https://forums.phpfreaks.com/topic/168319-how-to-stream-data-not-media-to-a-client-web-page/#findComment-887914 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.