Jump to content

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/162877-help-neede-on-a-kind-of-server-push/
Share on other sites

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.

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.