Stuck with Telnet still

Discussion in 'Ruby' started by Kingsley Hendrickse, Jul 4, 2003.

  1. 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_=--
    Kingsley Hendrickse, Jul 4, 2003
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. darrel
    Replies:
    6
    Views:
    346
    Darren Kopp
    Feb 28, 2006
  2. Jim Isaacson
    Replies:
    5
    Views:
    593
    Default User
    Nov 5, 2004
  3. Replies:
    1
    Views:
    130
    Guillaume Marcais
    Jun 30, 2003
  4. Carcarius
    Replies:
    0
    Views:
    275
    Carcarius
    Dec 6, 2007
  5. Une Bévue

    still stuck with rubygems-update

    Une Bévue, Jul 27, 2008, in forum: Ruby
    Replies:
    2
    Views:
    74
    Une Bévue
    Jul 30, 2008
Loading...

Share This Page