Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Stuck with Telnet still

Reply
Thread Tools

Stuck with Telnet still

 
 
Kingsley Hendrickse
Guest
Posts: n/a
 
      07-04-2003
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_=--

 
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
Telnet - attempting to initiate a telnet session within an established telnet session Carcarius Ruby 0 12-06-2007 03:26 AM
Still stuck with paramaterized SQL. darrel ASP .Net 6 02-28-2006 09:20 PM
Need to talk to a telnet server and send a telnet break Jim Isaacson C Programming 5 11-05-2004 09:17 PM
How can I telnet when I dont have specific access to a telnet client Jack B. Pollack Computer Support 4 07-24-2003 08:58 PM
Stuck in the middle with Telnet kingsley@icecode.org Ruby 1 06-30-2003 03:14 PM



Advertisments