semIT
asked on
How to use pipes
I want to use a pipe to transefer data between 2 applications. How can I do this.
http://www.jguru.com/faq/view.jsp?EID=464749
ASKER
I found that page earlier, however it doens't explain how to extablish a connection between two seperate aps
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I recall that on UNIX/LINUX you could do funny things however with a named pipe:
say there is a named pipe in /tmp: prwxrw-rw- myPipe
you could say:
java app1 >/tmp/myPipe & java app2 </tmp/myPipe &
with app1 writing to System.out while app2 reading System.in
Otherwise I think you must exchange data between 2 applications by a pair of sockets.
;JOOP!
say there is a named pipe in /tmp: prwxrw-rw- myPipe
you could say:
java app1 >/tmp/myPipe & java app2 </tmp/myPipe &
with app1 writing to System.out while app2 reading System.in
Otherwise I think you must exchange data between 2 applications by a pair of sockets.
;JOOP!
My last example supposes that the apps "don't know" about the pipe use.
The apps might as well open the pipe as if it was a file.
But the reader process will not ever encounter EOF! It will 'sleep' till more is written to the pipe.
;JOOP!
The apps might as well open the pipe as if it was a file.
But the reader process will not ever encounter EOF! It will 'sleep' till more is written to the pipe.
;JOOP!
ASKER
It is on a unix system and we are trying to link 2 java apps, so that one transmitts data to the other.
What would the code have to look like, talking about basic transmission.
What would the code have to look like, talking about basic transmission.
why don't you use RMI or sockets?
> however it doens't explain how to extablish a connection between two seperate aps
You just need to open the pipe as if it was a file.
You just need to open the pipe as if it was a file.
If you don't want to use RMI or sockets, simply create a thread in each
app, to take (f.i.) data from a Vector (thread-safe), open the pipe as a file to write to (ASCII? Binary?)
and expect the thread to sleep explicitly when the Vector becomes empty.
Likewise the 2nd app will have a thread that collects data from that pipe
and disposes the data in a suitable form into a Vector.
But this might not be the best solution in due course.
What can you tell about the final shape of those applications?
Between 2 systems you really should turn to RMI or sockets at least.
;JOOP!
app, to take (f.i.) data from a Vector (thread-safe), open the pipe as a file to write to (ASCII? Binary?)
and expect the thread to sleep explicitly when the Vector becomes empty.
Likewise the 2nd app will have a thread that collects data from that pipe
and disposes the data in a suitable form into a Vector.
But this might not be the best solution in due course.
What can you tell about the final shape of those applications?
Between 2 systems you really should turn to RMI or sockets at least.
;JOOP!
ASKER
It is a connection between a simple webcrawler and an indexer. To put the collected data into a database.
Well then, try the solution ....................
;JOOP!
;JOOP!