Forum: Ruby Ruby/tk slow threads?

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Tim M. (Guest)
on 2009-01-18 06:00
My code opens up a text window with an entry field. The text area gets
populated with the first spurt of text from the MUD, but then doesn't
update! Is my entry field not actually sending text to the server, or
are the threads for receiving text from the MUD going slow?

require 'tk'
require 'socket'

connection ="", 9898)

frame =>true, :fill=>:both)
entry =>:bottom, :fill=>:x)
t = do
  yscrollbar(>:right, :fill=>:y,
  pack(:side=>:left, :fill=>:both, :expand=>true)

killed = false do ||
    while killed == false
      inp = connection.recv(100)
      t.insert(:end, inp).see(:end)
    rescue StandardError
      puts $!

entry.bind('Return') do ||
  entry.delete(0, :end)


Hidetoshi NAGAI (Guest)
on 2009-01-22 06:59
(Received via mailing list)
From: Tim M. <removed_email_address@domain.invalid>
Subject: Ruby/tk slow threads?
Date: Sun, 18 Jan 2009 12:59:18 +0900
Message-ID: <removed_email_address@domain.invalid>
>       inp = connection.recv(100)
>       t.insert(:end, inp).see(:end)

        t.insert(:end, inp).see(:end) unless inp.empty?

> entry.bind('Return') do ||
>   connection.write(entry.value)

    connection.write(entry.value + "\n")  # ???

Though I don't know the protocol of your server,
does the server need "Return" at end of a command line?
Tim M. (Guest)
on 2009-01-22 07:03

Hmm, thats possible...
This topic is locked and can not be replied to.