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

Greetings all,
I have quite a conundrum on my hands, and its got me mightily stumped. I have a non-forking multiuser TCP server that I have running on my port 23, this is based mostly on the Perl Cookbook non-forking server in Chapter 17.

Now - heres the problem:
Depending on how I connect to the server, I can get a 20 character ascii-extended character piece of garbage that somehow appears before I type anything in from the client, thus the very first line that goes to the server is prefixed with it.
Now that, in itself, is pretty wierd -- magic text appearing from nowhere -- but it gets better!

telnet localhost 23 telnet localhost
Spot the difference! Yes, thats right, in one I explicitly define a port to connect to, and in the other I let telnet assume I mean port 23. Big deal, I hear you cry -- well apparently it is, because my garbage ONLY appears when I let telnet assume port 23.

Anyone got even the faintest idea what on earth is going on? This sounds ludicrous, but it really DOES happen!

JP,
-- Alexander Widdlemouse undid his bellybutton and his bum dropped off --

Replies are listed 'Best First'.
(tye)Re: 'telnet' sending bizarre ascii to perl server
by tye (Sage) on Mar 08, 2001 at 21:55 UTC

    The full 'telnet' protocol is more than just "connect and pump bytes", like many seem to assume. My guess is that your telnet client uses the full telnet protocol when not given a port number and avoids the optional negotiations (which your server doesn't understand) when given a specific port number (even if that port number is 23).

            - tye (but my friends call me "Tye")
      So what would be the way to make perl 'aware' of when telnet is coming-on-strong with the full protocol, rather than not?

      JP -- Alexander Widdlemouse undid his bellybutton and his bum dropped off --

        Well, modify your TCP server to use the telnet protocol if you wish to connect to it via telnet. Would you use a QuakeWorld client to connect to an FTP server?
        AgentM Systems nor Nasca Enterprises nor Bone::Easy nor Macperl is responsible for the comments made by AgentM. Remember, you can build any logical system with NOR.
        Maybe kick telnet, and use a raw-tcp client, like netcat. It's great tool for this kind of experiences.
        A quick search on google will help you to find it.
        ____________________
        Hope this helps

        It doesn't look (from a quick look) like Net::Telnet knows the Telnet protocol nor that some other module in CPAN does. O-: Perhaps someone would enjoy teaching it to Net::Telnet?

                - tye (but my friends call me "Tye")
Re: 'telnet' sending bizarre ascii to perl server
by Tuna (Friar) on Mar 08, 2001 at 21:59 UTC
    FWIW, is see no difference when I issue both commands on a Sun Ultra-2 running SunOS 5.6