terrordrone Posted June 19, 2009 Share Posted June 19, 2009 Hello, I have the following issue.. and i need some advice and ideas on how do i accomplish this. Lets say i simple java program that i can run on a server (prog A) which outputs 1 to N on the console with a delay of approx 1sec after each number. Now from prog B .. i do system.getruntime().exec("java progA 10") (N = 10) im able to capture the output of progA in progB using a buffered reader assuming progA and progB are on the server.. how do i make progB's output visible on the client in real time.. (something like a push from progB) The client has to be a browser. Ideas, pointers, tutorials etc will help me a great deal. Thanks in advance. Quote Link to comment https://forums.phpfreaks.com/topic/162877-help-neede-on-a-kind-of-server-push/ Share on other sites More sharing options...
corbin Posted June 19, 2009 Share Posted June 19, 2009 Not sure if this should technically be in Other Languages (since it appears to pertain to Java), but I know for sure it shouldn't have been in Client->Other. Anyway, you will not be able to use a buffered reader. (Well, not in the sense you mean anyway.) Not sure how this would work in Java, but you will need to open a stream from the program (never done it before in Java). In other words stdout (or what ever it's called in Java) from progA will need to be piped to a stream in progB some how... Oh, here's a question by the way... Is progB constantly running, or does it only run once? If it only runs once, you could do: progA 10 | progB And progA's stdout would be piped into progB's stdin. Anyway, once you figure out how to pipe output from progA's stdout into a stream in progB (sorry I can't help you with that x.x), then you can just use a blocking stream and read and output 1 byte at a time. You'll want to come up with a better solution though, like checking how much data is available and reading that or using non blocking reading if you're even going to transfer a lot of data since reading 1 byte at a time isn't exactly optimal. Quote Link to comment https://forums.phpfreaks.com/topic/162877-help-neede-on-a-kind-of-server-push/#findComment-859816 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.