commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1076609 - in /commons/proper/net/trunk/src: changes/changes.xml main/java/org/apache/commons/net/telnet/Telnet.java main/java/org/apache/commons/net/telnet/TelnetClient.java
Date Thu, 03 Mar 2011 13:05:32 GMT
Author: sebb
Date: Thu Mar  3 13:05:31 2011
New Revision: 1076609

URL: http://svn.apache.org/viewvc?rev=1076609&view=rev
Log:
NET-361 Implement Telnet Command sender.

Modified:
    commons/proper/net/trunk/src/changes/changes.xml
    commons/proper/net/trunk/src/main/java/org/apache/commons/net/telnet/Telnet.java
    commons/proper/net/trunk/src/main/java/org/apache/commons/net/telnet/TelnetClient.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=1076609&r1=1076608&r2=1076609&view=diff
==============================================================================
--- commons/proper/net/trunk/src/changes/changes.xml (original)
+++ commons/proper/net/trunk/src/changes/changes.xml Thu Mar  3 13:05:31 2011
@@ -54,6 +54,9 @@ The <action> type attribute can be add,u
 
     <body>
         <release version="3.0" date="TBA" description="TBA">
+            <action issue="NET-361" dev="sebb" type="add">
+            Implement Telnet Command sender.
+            </action>
             <action issue="NET-345" dev="sebb" type="fix" due-to="Archie Cobbs">
             Telnet client: not properly handling IAC bytes within subnegotiation messages:
             - failing to double IACs on output

Modified: commons/proper/net/trunk/src/main/java/org/apache/commons/net/telnet/Telnet.java
URL: http://svn.apache.org/viewvc/commons/proper/net/trunk/src/main/java/org/apache/commons/net/telnet/Telnet.java?rev=1076609&r1=1076608&r2=1076609&view=diff
==============================================================================
--- commons/proper/net/trunk/src/main/java/org/apache/commons/net/telnet/Telnet.java (original)
+++ commons/proper/net/trunk/src/main/java/org/apache/commons/net/telnet/Telnet.java Thu Mar
 3 13:05:31 2011
@@ -808,6 +808,19 @@ class Telnet extends SocketClient
     }
     /* open TelnetOptionHandler functionality (end)*/
 
+    /**
+     * Sends a command, automatically adds IAC prefix and flushes the output.
+     *
+     * @param cmd - command data to be sent
+     * @throws IOException - Exception in I/O.
+     **/
+    final synchronized void _sendCommand(byte cmd) throws IOException
+    {
+            _output_.write(TelnetCommand.IAC);
+            _output_.write(cmd);
+            _output_.flush();
+    }
+
     /* Code Section added for supporting AYT (start)*/
     /***
      * Processes the response of an AYT

Modified: commons/proper/net/trunk/src/main/java/org/apache/commons/net/telnet/TelnetClient.java
URL: http://svn.apache.org/viewvc/commons/proper/net/trunk/src/main/java/org/apache/commons/net/telnet/TelnetClient.java?rev=1076609&r1=1076608&r2=1076609&view=diff
==============================================================================
--- commons/proper/net/trunk/src/main/java/org/apache/commons/net/telnet/TelnetClient.java
(original)
+++ commons/proper/net/trunk/src/main/java/org/apache/commons/net/telnet/TelnetClient.java
Thu Mar  3 13:05:31 2011
@@ -231,6 +231,24 @@ public class TelnetClient extends Telnet
         _sendSubnegotiation(message);
     }
 
+    /***
+     * Sends a command byte to the remote peer, adding the IAC prefix.
+     *
+     * <p>
+     * This method does not wait for any response. Messages
+     * sent by the remote end can be handled by registering an approrpriate
+     * {@link TelnetOptionHandler}.
+     * </p>
+     *
+     * @param command the code for the command
+     * @throws IOException if an I/O error occurs while writing the message
+     ***/
+    public void sendCommand(byte command)
+    throws IOException, IllegalArgumentException
+    {
+        _sendCommand(command);
+    }
+
     /* open TelnetOptionHandler functionality (start)*/
 
     /***



Mime
View raw message