Jump to content

Recommended Posts

Hey all,

 

  FYI, this is my first post to this group, so be gentle  :shy:.

 

  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

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.

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'.

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....

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.