From: Robert Klemme Date: 2007-11-18T01:21:14+09:00 Subject: Re: call with async method 2007/11/17, Alex Young : > K. R. wrote: > > Hi @all > > > > I'm developing a tool who sniff the networktraffic on the nic. I would > > like to call the method asynchron from a other pc. I realize this > > problem with xmlrpc4r. To sniff the networkpackets, I use the pcaplet. > > > > Now, I want to stop the sniffing method also at the remote side. The > > idea is to set a global flag $state to boolean false. But it doesn't run > > correctly. You can see below the code from the remote class. > > > > Thanks for helping... > > > > ______________Sniffing class____________________ > > > > class Sniffer > > $state = true > > > > def start_sniffing > > @pcaplet = Pcaplet.new("-i eth0") > > # ...and so on.... > > > > for pkt in @pcaplet > > puts pkt.time > > break if $state == false # stop sniffing > > end > > end > > > > def stop_sniffing > > $state = false > > end > > end > > _________________________________________________ > > Not sure why you want a global for this. Wouldn't it be better to set > an @state instance variable in Sniffer's initialize method, and refer to > that in start_sniffing and stop_sniffing? Definitively. And also: KR, where do you do the sniffing? Is it in Pcaplet's constructor? In that case the flag would be useless. Cheers robert -- use.inject do |as, often| as.you_can - without end