0

I've followed this GitHub for an example of telnet server in Visual Studio C#. https://gist.github.com/UngarMax/6394321573dc0791dff9

I'm using cmd.exe to act as the client (running this command: telnet localhost 23). Alternatively it can run using telnet.exe (running this command: open localhost 23)

The above code allows user to input any message and press enter, if the message found, it will load the desire screen. Now I need to detect F1..F12 as a message to the server so that it can load the correct page. Anyone has any idea on it?

P.S.: I have tried detecting F1's hex code (0x70) but it doesn't really work.

  • "doing" a telnet server. "using cmd as my telnet client". Lets see if you can use the proper terms here hmmmm? "doing" would be "coding" or "writing". Assuming "cmd" is actually "cmd.exe", it is *not* a telnet client, but rather a command line interpreter. Windows comes with a telnet client called telnet.exe. – Sam Axe Sep 13 '17 at 07:10
  • If you are indeed coding a telnet server (or client), you should follow the [telnet rfc](https://tools.ietf.org/html/rfc854). – Sam Axe Sep 13 '17 at 07:20
  • i dont think the above link really helps – user3451430 Sep 13 '17 at 09:12

1 Answers1

-2

See this article: How to handle key press event in console application

You can detect F Keys with

if (keyinfo.Key == ConsoleKey.F1)
            {
                //do something
            }
Ohlsen1980
  • 294
  • 5
  • 11