why not use inetd or xinetd? they handle the sockets, sessions, concurrent connections, and host security parts pretty well...
They would listen to a specified port (23 or any other port, you could telnet hostname XXX to connect to port XXX) and run your script redirecting stdin/stdout to that connection.. Your script can be as simple as you want,dumb example:
#!/usr/bin/perl -w use strict; $|=1; print "What is your name?"; my $name=<>; chomp $name; print "Hello, $name, nice to meet you\n\n"; my $choice=''; while($choice ne 'q') { print "a. Print 1+1\n"; print "b. Print Hi\n"; print "q. Quit!\n"; $choice=<>; chomp $choice; if ($choice eq 'a') {print "1+1=2\n";} if ($choice eq 'b') {print "Hi $name !\n";} }

How to use xinetd on linux/unix:

remeber to disable output buffering $|=1

Simple: create a file /etc/xinetd.d/yourscriptname with

service yourscriptname { disable = no socket_type = stream wait = no user = root server = /path/to/your/script }

also add to your /etc/services:

yourscriptname portno/tcp

There are inetd ports to windows...


In reply to Re: Perl as a telnet server? by osama
in thread Perl as a telnet server? by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.