Stuck with Telnet still

Hi

I am still stuck with this telnet client :frowning:

I fyou copy and paste this code - and type guest after it runs - the intro
text pops up which is great and you can sit and watch the happenings on
the
mud - i.e. somebody does something etc. But you can’t type anything. The
aim is to have something listening constantly to the server to print to
the screen what is going on and have the ability to enter commands like
sit, walk etc. I can only get one or the other at the moment - this code
lets you watch but not type anything - if I change the ch =- sock.recv(1)
to ch = sock.read(1) and remove the loop and use while instead - I can
type stuff and watch the response - but then I have to keep hittinf a key
to see the server responses that are happening from other players and also
it is formatted badly and brings up the text in globs rather than the nice
way it loks when using sock.recv(1)

···

require 'socket’
require ‘thread’

sock = TCPSocket.new(‘ancient.anguish.org’,2222) # login name: guest (no
password needed)

t1 = Thread.new do
if line = gets
sock.write line
end
end

t2 = Thread.new do
loop do
ch = sock.recv(1)
putc ch
end
end

t1.join
t2.join

Thanks

Kingsley

I am still stuck with this telnet client :frowning:

Try something like this

svg% cat b.rb
#!/usr/bin/ruby
require 'socket'
require 'thread'

sock = TCPSocket.new('ancient.anguish.org',2222)
$stdout.sync = true

t1 = Thread.new do
   while line = gets
      sock.puts line
      break if /^quit/ =~ line
   end
end

t2 = Thread.new do
   loop do
      ch = sock.recv(1)
      putc ch
   end
end

t1.join

svg%

Guy Decoux

I am still stuck with this telnet client :frowning:

I fyou copy and paste this code - and type guest after it runs - the intro
text pops up which is great and you can sit and watch the happenings on
the
mud - i.e. somebody does something etc. But you can’t type anything.

Fairly understandable, since you’re only accepting one line from the
keyboard before that thread terminates:

t1 = Thread.new do
if line = gets
sock.write line
end
end

Regards,

Brian.

···

On Fri, Jul 04, 2003 at 11:23:48PM +0900, Kingsley Hendrickse wrote:

I Had also tried this with no luck - as it just doesn’t work at all:

require ‘socket’
require ‘thread’

sock = TCPSocket.new(‘ancient.anguish.org’,2222)
$stdout.sync = true

t1 = Thread.new do
loop do
while line = gets
sock.puts line
break if /^quit/ =~ line
end
end
end

t2 = Thread.new do
loop do
ch = sock.recv(1)
putc ch
end
end

t1.join

···

-----Original Message-----
From: Brian Candler [mailto:B.Candler@pobox.com]
Sent: Friday, July 04, 2003 4:46 PM
To: ruby-talk ML
Subject: Re: Stuck with Telnet still

On Fri, Jul 04, 2003 at 11:23:48PM +0900, Kingsley Hendrickse wrote:

I am still stuck with this telnet client :frowning:

I fyou copy and paste this code - and type guest after it runs - the
intro
text pops up which is great and you can sit and watch the happenings
on
the
mud - i.e. somebody does something etc. But you can’t type anything.

Fairly understandable, since you’re only accepting one line from the
keyboard before that thread terminates:

t1 = Thread.new do
if line = gets
sock.write line
end
end

Regards,

Brian.

I Had also tried this with no luck - as it just doesn’t work at all:

That code works perfectly for me under FreeBSD (see below).

As you’re under Windows then I think you should try the most recent 1.8.0
you can find, and if it still doesn’t work, report it as a bug.

Regards,

Brian.

help
Communications:
alt_soul, converse, dcommands, dsoul, earmuffs, echo, emote (:), language,
my,
pose, say ('), sayto (to), shout, squelch, tell, thistory, unsquelch,
whisper

Information:
abilities, alarm, bounty, brief, capname, date, email, equipment (eq),
evaluate (eval), examine (exa), feel, fortune, gm, help, homepage,
inventory (i), listen, look (l), measurement, muds, npc, oldnews, password,
peer, prompt, pueblo, qwho, rivers, score (sc), search, skills, smell,
stats, suicide, taste, thistory, time, timezone, touch, view, who,
wizardlist

Races and classes:
clerics, cleric levels, dwarves, elves, fighters, fighter levels,
half-elves, humans, levels, mages, mage levels, necromancers, necro levels,
orcs, paladins, paladin levels, rangers, ranger levels, rogues,
shapeshifters
shapeshifter levels.

Combat:
aim, attack, combat, choose, defend, kill, kill-markers, kneel, lie,
positions,
powerup, report, rescue, sit, skills, stand, stats, stop, weapons, wear,
wield,
wimpy
–More–(21/39)
Lest enters the game.
Lest leaves south.
Kalyn raises an eyebrow at Malvin.
Kalyn gives something to Star.
A huge trained wolf gags on a beef brisket, then drops it.
Kalyn takes a beef brisket.
Neff slowly turns into a stone statue.

···

On Sat, Jul 05, 2003 at 06:25:57AM +0900, Kingsley wrote:

I suppose I/O still blocks the whole interpreter in windows.
I had problem with:

Thread.new {
while(true)
puts “Hello!”
sleep 1
end
}
Thread.new {
while(true)
puts “Hello2!”
sleep 1
end
}
while(true)
printf gets
end

( latest PragProg installer )

Obviously it runs fune on unices

···

il Sat, 5 Jul 2003 07:09:55 +0900, Brian Candler B.Candler@pobox.com ha scritto::

On Sat, Jul 05, 2003 at 06:25:57AM +0900, Kingsley wrote:

I Had also tried this with no luck - as it just doesn’t work at all:

That code works perfectly for me under FreeBSD (see below).

As you’re under Windows then I think you should try the most recent 1.8.0
you can find, and if it still doesn’t work, report it as a bug.