Author: sebb
Date: Sun Jul 11 22:00:50 2010
New Revision: 963152
URL: http://svn.apache.org/viewvc?rev=963152&view=rev
Log:
NET-180 Telnet EOR is "consumed" by TelnetInputStream when in BINARY
transmission
Modified:
commons/proper/net/branches/NET_2_0/src/main/java/org/apache/commons/net/telnet/Telnet.java
commons/proper/net/branches/NET_2_0/src/main/java/org/apache/commons/net/telnet/TelnetInputStream.java
commons/proper/net/branches/NET_2_0/src/main/java/org/apache/commons/net/telnet/TelnetNotificationHandler.java
Modified:
commons/proper/net/branches/NET_2_0/src/main/java/org/apache/commons/net/telnet/Telnet.java
URL:
http://svn.apache.org/viewvc/commons/proper/net/branches/NET_2_0/src/main/java/org/apache/commons/net/telnet/Telnet.java?rev=963152&r1=963151&r2=963152&view=diff
==============================================================================
---
commons/proper/net/branches/NET_2_0/src/main/java/org/apache/commons/net/telnet/Telnet.java
(original)
+++
commons/proper/net/branches/NET_2_0/src/main/java/org/apache/commons/net/telnet/Telnet.java
Sun Jul 11 22:00:50 2010
@@ -406,6 +406,25 @@ class Telnet extends SocketClient
}
/**
+ * Processes a COMMAND.
+ *
+ * @param command - option code to be set.
+ **/
+ void _processCommand(int command)
+ {
+ if (debugoptions)
+ {
+ System.err.println("RECEIVED COMMAND: " + command);
+ }
+
+ if (__notifhand != null)
+ {
+ __notifhand.receivedNegotiation(
+ TelnetNotificationHandler.RECEIVED_COMMAND, command);
+ }
+ }
+
+ /**
* Processes a DO request.
*
* @param option - option code to be set.
Modified:
commons/proper/net/branches/NET_2_0/src/main/java/org/apache/commons/net/telnet/TelnetInputStream.java
URL:
http://svn.apache.org/viewvc/commons/proper/net/branches/NET_2_0/src/main/java/org/apache/commons/net/telnet/TelnetInputStream.java?rev=963152&r1=963151&r2=963152&view=diff
==============================================================================
---
commons/proper/net/branches/NET_2_0/src/main/java/org/apache/commons/net/telnet/TelnetInputStream.java
(original)
+++
commons/proper/net/branches/NET_2_0/src/main/java/org/apache/commons/net/telnet/TelnetInputStream.java
Sun Jul 11 22:00:50 2010
@@ -212,8 +212,9 @@ final class TelnetInputStream extends Bu
__receiveState = _STATE_DATA;
break; // exit to enclosing switch to return IAC from read
default:
- __receiveState = _STATE_DATA;
- continue; // move on the next char, i.e. ignore IAC+unknown
+ __receiveState = _STATE_DATA;
+ __client._processCommand(ch); // Notify the user
+ continue; // move on the next char
}
break; // exit and return from read
case _STATE_WILL:
@@ -382,7 +383,7 @@ final class TelnetInputStream extends Bu
__readIsWaiting = true;
int ch;
boolean mayBlock = true; // block on the first read
only
-
+
do
{
try
@@ -421,7 +422,7 @@ final class TelnetInputStream extends Bu
if (__isClosed)
return EOF;
}
-
+
// Reads should not block on subsequent
iterations. Potentially, this could happen if the
// remaining buffered socket data consists
entirely of Telnet command sequence and no "user" data.
mayBlock = false;
Modified:
commons/proper/net/branches/NET_2_0/src/main/java/org/apache/commons/net/telnet/TelnetNotificationHandler.java
URL:
http://svn.apache.org/viewvc/commons/proper/net/branches/NET_2_0/src/main/java/org/apache/commons/net/telnet/TelnetNotificationHandler.java?rev=963152&r1=963151&r2=963152&view=diff
==============================================================================
---
commons/proper/net/branches/NET_2_0/src/main/java/org/apache/commons/net/telnet/TelnetNotificationHandler.java
(original)
+++
commons/proper/net/branches/NET_2_0/src/main/java/org/apache/commons/net/telnet/TelnetNotificationHandler.java
Sun Jul 11 22:00:50 2010
@@ -53,13 +53,18 @@ public interface TelnetNotificationHandl
public static final int RECEIVED_WONT = 4;
/***
- * Callback method called when TelnetClient receives an option
- * negotiation command.
+ * The remote party sent a COMMAND.
+ ***/
+ public static final int RECEIVED_COMMAND = 5;
+
+ /***
+ * Callback method called when TelnetClient receives an
+ * command or option negotiation command
* <p>
- * @param negotiation_code - type of negotiation command received
- * (RECEIVED_DO, RECEIVED_DONT, RECEIVED_WILL, RECEIVED_WONT)
+ * @param negotiation_code - type of (negotiation) command received
+ * (RECEIVED_DO, RECEIVED_DONT, RECEIVED_WILL, RECEIVED_WONT,
RECEIVED_COMMAND)
* <p>
- * @param option_code - code of the option negotiated
+ * @param option_code - code of the option negotiated, or the command code
itself (e.g. NOP).
* <p>
***/
public void receivedNegotiation(int negotiation_code, int option_code);