![]() |
Stuck with Telnet still
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"> </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"> </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"> </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"> </font> <br><font size=2 face="sans-serif"> t1.join</font> <br><font size=2 face="sans-serif"> 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_=-- |
| All times are GMT. The time now is 06:59 AM. |
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.