About using drb to read data

In my codes , I use drb to read data from a pipe. I want to read the
pipe data and let them show in client as well as in server. But it
cannot done successfully.The results show the pipe date will be splitted
in server point and client point,and always error “dmon.rb:63:in
`write’: Broken pipe - (Errno::EPIPE)”. I google this issue
,and it says pipe data cannot read more than once. So I ask for help in
this platform. I need your help.Thank you.

On Fri, Jun 8, 2012 at 5:15 AM, dongcan z. [email protected] wrote:

In my codes , I use drb to read data from a pipe. I want to read the

AFAIK DRb uses sockets and not pipes…

pipe data and let them show in client as well as in server. But it
cannot done successfully.The results show the pipe date will be splitted
in server point and client point,and always error “dmon.rb:63:in
`write’: Broken pipe - (Errno::EPIPE)”. I google this issue
,and it says pipe data cannot read more than once. So I ask for help in
this platform. I need your help.Thank you.

Can you show the code? Otherwise it will be difficult to help.

Kind regards

robert

Robert K. wrote in post #1063691:

On Fri, Jun 8, 2012 at 5:15 AM, dongcan z. [email protected] wrote:

In my codes , I use drb to read data from a pipe. I want to read the

AFAIK DRb uses sockets and not pipes…

pipe data and let them show in client as well as in server. But it
cannot done successfully.The results show the pipe date will be splitted
in server point and client point,and always error “dmon.rb:63:in
`write’: Broken pipe - (Errno::EPIPE)”. I google this issue
,and it says pipe data cannot read more than once. So I ask for help in
this platform. I need your help.Thank you.

Can you show the code? Otherwise it will be difficult to help.

Kind regards

robert

The code is like this:
#in the server
########################
class Drb_server
include DRb::DRbObservable
def initialize out
@pipe= out
end
def invoke_client
while [email protected]
changed
notify_observers(line)
end
end
end
#The class below is a class that calls class Drb_server and output data
#through a pipe
class Main
def start
@s_out=IO.popen(…a command line that can execute)
d_server=DRb_server.new @s_out
DRb.start_service(uri,d_server)
end
def info_output
while [email protected]_out.gets
puts str_line
end
end
end
#Next is the execute codes
task=Main.new
task.start
task.info_output

####################
#in the drb client
require ‘drb/drb’
class Show
include DRbUndumped
def update(value)
puts value
end
end
monitor=DRbObject.new_with_uri(server_uri)
shower=Show.new
monitor.add_observer(shower)
monitor.invoke_client

I want to output the see the output both in server and in the client.But
this can not success. So I wonder if you can give me some suggestions.
Thank you!

add it to client.

shower=Show.new
+DRb.start_service
monitor.add_observer(shower)

SEKI Masatoshi wrote in post #1063979:

add it to client.

shower=Show.new
+DRb.start_service
monitor.add_observer(shower)

Sorry I forgot to Ctrl+v this line. It has already been there. But the
output can not been seen both in the server and the client. The code has
complied and run successfully, so it has not a error when running it.

Robert K. wrote in post #1064956:

On Tue, Jun 12, 2012 at 3:37 AM, dongcan z. [email protected]
wrote:

complied and run successfully, so it has not a error when running it.
Compiled? OK, can you explain with your own words what this is
supposed to do? Do you want to send all lines read from the command
to all listeners? Documentation on DRb::DRbObservable seems to be a
bit thin so I’d have to do some experimenting.

Kind regards

robert

The purpose is to show the output of the command both in the drb server
and clients. Maybe because of the popen, it’s like a pipe, the output is
a stream, I found the result was like that the stream was cut up and the
parts were scattered in the server and clients. I want to see the whole
stream . Thanks again for your attention!

Best regards

On Tue, Jun 12, 2012 at 3:37 AM, dongcan z. [email protected]
wrote:

complied and run successfully, so it has not a error when running it.
Compiled? OK, can you explain with your own words what this is
supposed to do? Do you want to send all lines read from the command
to all listeners? Documentation on DRb::DRbObservable seems to be a
bit thin so I’d have to do some experimenting.

Kind regards

robert