Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > IO.getc (Based off of #45 MUD)

Reply
Thread Tools

IO.getc (Based off of #45 MUD)

 
 
Ari Brown
Guest
Posts: n/a
 
      07-25-2007
I have some questions about sockets, IO.getc(), and IO.ready?().


So my telnet server accepts
connections. That works.
It displays the
prompt.
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?).

CODE:
loop do
character = sock.getc
if sock.ready?
# puts sock.ready?
# puts sock
case character
when ?\C-c
print "^C"
# break
when ?\r, ?\n, ?\C-M
$writer[$output_buffer]
show_prompt
else
$output_buffer << character
print character.chr
end
end

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

What's going on?

Thanks,
-------------------------------------------------------|
~ Ari


 
Reply With Quote
 
 
 
 
James Edward Gray II
Guest
Posts: n/a
 
      07-26-2007
On Jul 25, 2007, at 4:35 PM, Ari Brown wrote:

> So my telnet server accepts
> connections. That works.
> It displays the
> prompt.
> 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?????? ??!??"??'????


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:

http://rubyquiz.com/quiz32.html

James Edward Gray II

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Viewstate wont turn off even after setting it to off ! robert112 ASP .Net 1 04-26-2007 01:51 AM
PC to PC: on-off-on-off etc. =?Utf-8?B?bm9wZnVzY2g=?= Wireless Networking 0 06-07-2006 06:35 PM
Can ANT shut off or detect when a service is shut off? Steve Java 0 01-31-2006 02:40 AM
Off topic: are we killing off the small to emdium web design firms? Wayne... HTML 15 07-23-2004 01:05 AM
Logon, off, on, off, on arghhhhh Sven Computer Support 18 06-15-2004 03:52 PM



Advertisments