Stuck with Telnet still

  • Thread starter Kingsley Hendrickse
  • Start date
K

Kingsley Hendrickse

This is a multipart message in MIME format.
--=_alternative 004F116780256D59_=
Content-Type: text/plain; charset="us-ascii"

Hi

I am still stuck with this telnet client :(

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
--=_alternative 004F116780256D59_=
Content-Type: text/html; charset="us-ascii"


<br><font size=2 face="sans-serif">Hi </font>
<br>
<br><font size=2 face="sans-serif">I am still stuck with this telnet client :(</font>
<br>
<br><font size=2 face="sans-serif">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</font>
<br><font size=2 face="sans-serif">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) </font>
<br>
<br><font size=2 face="sans-serif">-----------------------------------</font>
<br><font size=2 face="sans-serif">require 'socket'</font>
<br><font size=2 face="sans-serif">require 'thread'</font>
<br><font size=2 face="sans-serif">&nbsp;</font>
<br><font size=2 face="sans-serif">sock = TCPSocket.new('ancient.anguish.org',2222) # login name: guest (no password needed)</font>
<br><font size=2 face="sans-serif">&nbsp;</font>
<br><font size=2 face="sans-serif">t1 = Thread.new do</font>
<br><font size=2 face="sans-serif">if line = gets</font>
<br><font size=2 face="sans-serif">sock.write line</font>
<br><font size=2 face="sans-serif">end</font>
<br><font size=2 face="sans-serif">end</font>
<br><font size=2 face="sans-serif">&nbsp;</font>
<br><font size=2 face="sans-serif">t2 = Thread.new do</font>
<br><font size=2 face="sans-serif">loop do </font>
<br><font size=2 face="sans-serif">ch = sock.recv(1)</font>
<br><font size=2 face="sans-serif">putc ch</font>
<br><font size=2 face="sans-serif">end</font>
<br><font size=2 face="sans-serif">end</font>
<br><font size=2 face="sans-serif">&nbsp; </font>
<br><font size=2 face="sans-serif">&nbsp;t1.join</font>
<br><font size=2 face="sans-serif">&nbsp;t2.join</font>
<br><font size=2 face="sans-serif">------------------------------------</font>
<br>
<br><font size=2 face="sans-serif">Thanks</font>
<br>
<br><font size=2 face="sans-serif">Kingsley</font>
--=_alternative 004F116780256D59_=--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,731
Messages
2,569,432
Members
44,832
Latest member
GlennSmall

Latest Threads

Top