Hiya
Thanks - I just about worked that out - lol sorry - I now have another
threading problem though:
require 'net/telnet'
require 'thread'
require 'net/telnet'
tn = Net::Telnet.new('Host' => 'ancient.anguish.org',
'Port' => '2222',
'Telnetmode' => true) { |str| print str }
tn.cmd("String" => "guest") { |str| print str }
thr4 = Thread.new() do
loop do
tn.cmd(gets.chomp) { |str| print str }
end
end
thr3 = Thread.new() do
loop do
tn.waitfor("Match" => /.+/) { |str| print str }
end
end
thr4.join
I have one thread to enter commands into the server and one thread to
listen to all the server repsonses that are going on all the time.
But this code here - it lets me enter 1 command - then it just listens
and I cant enter anymore commands
Any clue?
Thanks
Kingsley
Hi
When I do this:
thr3 = Thread.new() do
loop do
puts \"thread\"
end
endThe loop only lasts for about 5 seconds - printing out
\'thread\' about
100 timesTo answer the question in the subject: yes, threading does work
properlyWhen the main thread of your program reaches the end, all other
threads are
killed too.Add the following line at the end:
thr3.join
(which means "wait for thr3 to finish", which of course it never
does).
···
On 06-30-2003 05:20 pm, you wrote:
On Tue, Jul 01, 2003 at 01:12:50AM +0900, kingsley@icecode.org wrote:
Regards,
Brian.