You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by se...@apache.org on 2014/08/07 19:44:11 UTC
svn commit: r1616555 - in /commons/proper/net/trunk/src: changes/changes.xml
main/java/examples/telnet/TelnetClientExample.java
Author: sebb
Date: Thu Aug 7 17:44:11 2014
New Revision: 1616555
URL: http://svn.apache.org/r1616555
Log:
Added control character processing to TelnetClientExample
Modified:
commons/proper/net/trunk/src/changes/changes.xml
commons/proper/net/trunk/src/main/java/examples/telnet/TelnetClientExample.java
Modified: commons/proper/net/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/net/trunk/src/changes/changes.xml?rev=1616555&r1=1616554&r2=1616555&view=diff
==============================================================================
--- commons/proper/net/trunk/src/changes/changes.xml [utf-8] (original)
+++ commons/proper/net/trunk/src/changes/changes.xml [utf-8] Thu Aug 7 17:44:11 2014
@@ -68,6 +68,9 @@ This is mainly a bug-fix release. See fu
IMAPExportMbox (example app) allows IMAP folders to be exported into an mbox file.
This is the inverse of the IMAPImportMbox example added previously
">
+ <action type="update" dev="sebb">
+ Added control character processing to TelnetClientExample
+ </action>
<action issue="NET-547" type="fix" dev="sebb" due-to="Fabio Scippacercola">
There is a lack of documentation regarding setControlKeepAliveTimeout
</action>
Modified: commons/proper/net/trunk/src/main/java/examples/telnet/TelnetClientExample.java
URL: http://svn.apache.org/viewvc/commons/proper/net/trunk/src/main/java/examples/telnet/TelnetClientExample.java?rev=1616555&r1=1616554&r2=1616555&view=diff
==============================================================================
--- commons/proper/net/trunk/src/main/java/examples/telnet/TelnetClientExample.java (original)
+++ commons/proper/net/trunk/src/main/java/examples/telnet/TelnetClientExample.java Thu Aug 7 17:44:11 2014
@@ -122,6 +122,7 @@ public class TelnetClientExample impleme
System.out.println("Type UNREGISTER to unregister an OptionHandler");
System.out.println("Type SPY to register the spy (connect to port 3333 to spy)");
System.out.println("Type UNSPY to stop spying the connection");
+ System.out.println("Type ^[A-Z] to send the control character; use ^^ to send ^");
reader.start();
OutputStream outstr = tc.getOutputStream();
@@ -217,6 +218,16 @@ public class TelnetClientExample impleme
{
tc.stopSpyStream();
}
+ else if((new String(buff, 0, ret_read)).matches("^\\^[A-Z^]\\r?\\n?$"))
+ {
+ byte toSend = buff[1];
+ if (toSend == '^') {
+ outstr.write(toSend);
+ } else {
+ outstr.write(toSend - 'A' + 1);
+ }
+ outstr.flush();
+ }
else
{
try