narse has asked for the wisdom of the Perl Monks concerning the following question:

I am writing a game server using POE::Component::Server::TCP and I have run into an issue with telnet modes. I do not want telnet to wait for the trailing \n before it sends its data to the server. To fix this, I can force telnet into character mode but this is inconvenient.

I am looking for a way to make the server I am writing ask the telnet client politely to switch into character mode (or some similar fix). Is there a module or some sample server code that will instruct telnet clients to change their settings?

Replies are listed 'Best First'.
Re: Telnet Modes
by shenme (Priest) on Aug 22, 2003 at 07:14 UTC
    You can find most (all?) of the relevant RFCs in a list at Application Protocols - TELNET

    You might want to wade through the RFCs that have interesting titles, though you'll have to apply some judgement here ... (e.g. TELNET RANDOMLY-LOSE Option   TELNET SUBLIMINAL-MESSAGE Option)

    I scanned through some of these looking for what I think you might want - the ability to tell clients "send me whatever you've got in your input buffer if more than X time has elapsed since last character entry".   None of the RFCs seemed to mention such a thing.

    But I might be confused as your two paragraphs above seem to contradict each other?   You find character mode 'inconvenient' but are looking for a way to "instruct telnet clients to change their settings?"

    Another bit of code that might be instructive is Net::Telnet which demonstrates handling Telnet option negotiation.

Re: Telnet Modes
by castaway (Parson) on Aug 25, 2003 at 12:38 UTC
    There are a couple of ways to do it, which have varying degrees of success, depending on which clients you get.

    1. Theres a telnet option called LINEMODE, in which if you *dont* set the EDIT option, means the client should use/be in char mode.

    2. Plenty of clients don't know a thing about LINEMODE, in which case you can try DO SGA. (Which was/is originally an option to turn off GoAhead, but is recognised by a lot of clients as 'do charmode', apparently). Also, some clients insist on both 'WILL SGA' *and* 'DO SGA' before they actually do charmode.

    You might need to send a 'Don't echo' option as well to get these to work.

    C.

    (Information gleaned from an experienced MUD server person - see also RFC 858 )

      Yes, Thank You. It turns out that suppress go ahead is what I really wanted. It took me some time to figure this out, but I needed to translate the dec values to oct and send them that way.

      The code I am using now looks like this:
      # send IAC WILL SUPPRESS-GOAHEAD put( "\377\373\3\n" ); # send IAC DO SUPPRESS-GO-AHEAD put( "\377\375\3\n" );
      (where put() sends a scalar argument to the user)

      Thanks all for your responses.
Re: Telnet Modes
by waswas-fng (Curate) on Aug 22, 2003 at 06:45 UTC
    since you are running a tcp server and expecting to control telnet behavior on the client side you may want to look at the telnet RFC and implement the protocol's way of setting buffering - more info can be had at here.

    -Waswas
Re: Telnet Modes
by davido (Cardinal) on Aug 22, 2003 at 04:40 UTC
    This may be implementation specific, but have you tried setting $| to some non-zero value? Per the Camel book (and other sources such as perldocs):


    If set to nonzero, forces an fflush(3) after every write or print on the currently selected output channel.

    I haven't tested it in the context of telnet, but it might be worth giving it a whirl.

    Good luck.

    Dave

    "If I had my life to do over again, I'd be a plumber." -- Albert Einstein

      Er, I'm fairly certain that would only affect the server, I think he's asking about the client.
        Yes. The client will not send data until the \n but the server happily will. I do not believe $| is the issue here.