IO.getc (Based off of #45 MUD)


I have some questions about sockets, IO.getc(), and IO.ready?().

So my telnet server accepts
connections. That works.
It displays the
That works.
It accepts the single characters (IO.getc) without pressing return.
That works.
But wait! Whenever I connect to the server (telnet localhost), there
is always this string of characters that are:

??%??&??&??^C??? ???"??’???

Where are those characters coming from, and is there a suitable
workaround? I tried instituting a sleep 1 to allow the characters to
pass (assuming it was a short stream), but they still came. I also
noticed that this only happens when I press enter (which for me shows
up a ^M. bwah?).

loop do
character = sock.getc
if sock.ready?

puts sock.ready?

puts sock

       case character
       when ?\C-c
         print "^C"


       when ?\r, ?\n, ?\C-M
         $output_buffer << character
         print character.chr

I had to comment out ‘break’ so that I wouldn’t get disconnected
during the initial character stream.

What’s going on?

~ Ari


On Jul 25, 2007, at 4:35 PM, Ari B. wrote:

??%??&??&??^C??? ???"??’???
Those are telnet codes you will need to recognize and remove. Your
client sends those to determine the features of the server. I
discuss this a little and give code for it in this old quiz summary:

James Edward G. II