Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
The problem is that the call to "ReadMode(4)" result in error and close of the client: "GetConsoleMode failed, LastError=|6| at C:/Perl/lib/Term/ReadKey.pm line 265" BTW, the script should run on linux and windows. Thanks, Dayan Shay#!perl -w use strict; use NetServer::Generic; use Term::ReadKey; sub Terminal { my ($server) = @_; my $input; my $key; while (1) { ReadMode(4); while (not defined ($key = ReadKey(0))) {}; ReadMode(0); if ($key eq "q") { return 1; } else { print "Got character '" . ord($key) . "'\r\n"; } }; return 0; } my $Server = new NetServer::Generic; $Server->port(23); $Server->callback(\&Terminal); $Server->mode("forking"); print "Starting server\n"; $Server->run();
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Telnet server that read a single character
by BrowserUk (Patriarch) on Apr 08, 2010 at 07:13 UTC | |
|
Re: Telnet server that read a single character
by sflitman (Hermit) on Apr 08, 2010 at 05:41 UTC | |
by Anonymous Monk on Apr 08, 2010 at 08:48 UTC | |
by shupup (Initiate) on Apr 13, 2010 at 06:49 UTC | |
by Anonymous Monk on May 18, 2011 at 15:58 UTC |