Java Telnet Apache Commons:如何发送功能键? [英] Java Telnet Apache Commons: How to send functions keys?

查看:86
本文介绍了Java Telnet Apache Commons:如何发送功能键?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Apache Commons telnet库对与服务器的Java连接进行编程.我已经在修改了示例代码 http://www.java2s.com/Code/Java/Network-Protocol /ExampleofuseofTelnetClient.htm 连接到我们的服务器并进行测试.一切似乎都正常,但我不知道如何通过telnet发送功能按键.

I am programming a Java connection to a server using the Apache commons telnet library. I have modified the example code at http://www.java2s.com/Code/Java/Network-Protocol/ExampleofuseofTelnetClient.htm to connect to our server and preform tests. Everything seems to work fine but I cannot figure out how to send function key presses over telnet.

在我们的IBM 3151模拟器上使用嗅探器作为功能键"F9"后,我得到了值:"/033i/r",但仅键入此命令无效.我认为这只是在我键入文字时发送这些文字字符.

After using a sniffer with our IBM 3151 emulator for the function key 'F9' I got the value: '/033i/r', but simply just typing this in does not work. I figure it is just sending those text characters when I simply type them.

我想我只是错过了一些简单的东西,但是经过几个小时的搜索后似乎找不到任何信息.

I'd imagine that I just missing something simple but I cannot seem to find any information after searching for a few hours.

推荐答案

搜索了更长的时间后,我发现必须将字节数组中的ASCII十六进制字符发送到与终端相对应的telnet会话的outputStream上我正在使用的类型.

After searching for a bit longer I found that I had to send the ASCII hex characters in a byte array to the outputStream of the telnet session that corresponded to the terminal type I was using.

因此要发送'/033i/r',这是功能键:'F9'的代码,我创建了以下字节数组:

Thus to send '/033i/r' which is the code for the function key: 'F9', I created the following byte array:

byte[] toSend = new byte[] { (byte)0x1b, (byte)0x69, (byte)0x0d } ;

因此,您需要知道用于telnet连接的终端仿真,以及功能键的映射.

So you need to know which terminal emulation you are using for your telnet connection, and what the function keys map too.

这篇关于Java Telnet Apache Commons:如何发送功能键?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆