Search code examples
c#asp.nettelnettcpclientnetworkstream

telnet session sending 'F3' key to TcpClient using network stream


i am making telnet session using c# and wanna to send 'F3' to the session

TcpClient oClient = new TcpClient();
oClient.Connect(IP, 23);  
NetworkStream ns = oClient.GetStream();
string msg=""// here to send 'F3' key
ns.Write(msg, 0, msg.Length);

i tried "{F3}" and "\033[13~" but didn't work


Solution

  • The underlying data here is just a TCP stream that has no concept of a keyboard, so the real question is: what does the other end expect to that it is interpreting as F3? One way to do this would be to set up a dummy TCP dump console exe (server) and have a working client connect and press F3 - inspect what was sent. However, there are some likely candidates, including:

    • "^[[13~"
    • "\033[13~"
    • "\x1bOR"

    (for different client/server implementations)