code
stringlengths 25
201k
| docstring
stringlengths 19
96.2k
| func_name
stringlengths 0
235
| language
stringclasses 1
value | repo
stringlengths 8
51
| path
stringlengths 11
314
| url
stringlengths 62
377
| license
stringclasses 7
values |
|---|---|---|---|---|---|---|---|
public boolean getTcpNoDelay() throws SocketException
{
return _socket_.getTcpNoDelay();
}
|
Returns true if Nagle's algorithm is enabled on the currently opened
socket.
<p>
@return True if Nagle's algorithm is enabled on the currently opened
socket, false otherwise.
@exception SocketException If the operation fails.
@throws NullPointerException if the socket is not currently open
|
getTcpNoDelay
|
java
|
alibaba/arthas
|
client/src/main/java/org/apache/commons/net/SocketClient.java
|
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/SocketClient.java
|
Apache-2.0
|
public boolean getKeepAlive() throws SocketException {
return _socket_.getKeepAlive();
}
|
Returns the current value of the SO_KEEPALIVE flag on the currently opened socket.
Delegates to {@link Socket#getKeepAlive()}
@return True if SO_KEEPALIVE is enabled.
@throws SocketException if there is a problem with the socket
@throws NullPointerException if the socket is not currently open
@since 2.2
|
getKeepAlive
|
java
|
alibaba/arthas
|
client/src/main/java/org/apache/commons/net/SocketClient.java
|
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/SocketClient.java
|
Apache-2.0
|
public void setSoLinger(boolean on, int val) throws SocketException
{
_socket_.setSoLinger(on, val);
}
|
Sets the SO_LINGER timeout on the currently opened socket.
<p>
@param on True if linger is to be enabled, false if not.
@param val The linger timeout (in hundredths of a second?)
@exception SocketException If the operation fails.
@throws NullPointerException if the socket is not currently open
|
setSoLinger
|
java
|
alibaba/arthas
|
client/src/main/java/org/apache/commons/net/SocketClient.java
|
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/SocketClient.java
|
Apache-2.0
|
public int getSoLinger() throws SocketException
{
return _socket_.getSoLinger();
}
|
Returns the current SO_LINGER timeout of the currently opened socket.
<p>
@return The current SO_LINGER timeout. If SO_LINGER is disabled returns
-1.
@exception SocketException If the operation fails.
@throws NullPointerException if the socket is not currently open
|
getSoLinger
|
java
|
alibaba/arthas
|
client/src/main/java/org/apache/commons/net/SocketClient.java
|
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/SocketClient.java
|
Apache-2.0
|
public int getRemotePort()
{
return _socket_.getPort();
}
|
Returns the port number of the remote host to which the client is
connected.
Delegates to {@link Socket#getPort()}
<p>
@return The port number of the remote host to which the client is
connected.
@throws NullPointerException if the socket is not currently open
|
getRemotePort
|
java
|
alibaba/arthas
|
client/src/main/java/org/apache/commons/net/SocketClient.java
|
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/SocketClient.java
|
Apache-2.0
|
public InetAddress getRemoteAddress()
{
return _socket_.getInetAddress();
}
|
@return The remote address to which the client is connected.
Delegates to {@link Socket#getInetAddress()}
@throws NullPointerException if the socket is not currently open
|
getRemoteAddress
|
java
|
alibaba/arthas
|
client/src/main/java/org/apache/commons/net/SocketClient.java
|
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/SocketClient.java
|
Apache-2.0
|
public void setSocketFactory(SocketFactory factory)
{
if (factory == null) {
_socketFactory_ = __DEFAULT_SOCKET_FACTORY;
} else {
_socketFactory_ = factory;
}
// re-setting the socket factory makes the proxy setting useless,
// so set the field to null so that getProxy() doesn't return a
// Proxy that we're actually not using.
connProxy = null;
}
|
Sets the SocketFactory used by the SocketClient to open socket
connections. If the factory value is null, then a default
factory is used (only do this to reset the factory after having
previously altered it).
Any proxy setting is discarded.
<p>
@param factory The new SocketFactory the SocketClient should use.
|
setSocketFactory
|
java
|
alibaba/arthas
|
client/src/main/java/org/apache/commons/net/SocketClient.java
|
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/SocketClient.java
|
Apache-2.0
|
public void setServerSocketFactory(ServerSocketFactory factory) {
if (factory == null) {
_serverSocketFactory_ = __DEFAULT_SERVER_SOCKET_FACTORY;
} else {
_serverSocketFactory_ = factory;
}
}
|
Sets the ServerSocketFactory used by the SocketClient to open ServerSocket
connections. If the factory value is null, then a default
factory is used (only do this to reset the factory after having
previously altered it).
<p>
@param factory The new ServerSocketFactory the SocketClient should use.
@since 2.0
|
setServerSocketFactory
|
java
|
alibaba/arthas
|
client/src/main/java/org/apache/commons/net/SocketClient.java
|
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/SocketClient.java
|
Apache-2.0
|
public ServerSocketFactory getServerSocketFactory() {
return _serverSocketFactory_;
}
|
Get the underlying {@link ServerSocketFactory}
@return The server socket factory
@since 2.2
|
getServerSocketFactory
|
java
|
alibaba/arthas
|
client/src/main/java/org/apache/commons/net/SocketClient.java
|
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/SocketClient.java
|
Apache-2.0
|
protected void fireReplyReceived(int replyCode, String reply) {
if (getCommandSupport().getListenerCount() > 0) {
getCommandSupport().fireReplyReceived(replyCode, reply);
}
}
|
If there are any listeners, send them the reply details.
@param replyCode the code extracted from the reply
@param reply the full reply text
@since 3.0
|
fireReplyReceived
|
java
|
alibaba/arthas
|
client/src/main/java/org/apache/commons/net/SocketClient.java
|
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/SocketClient.java
|
Apache-2.0
|
protected void fireCommandSent(String command, String message) {
if (getCommandSupport().getListenerCount() > 0) {
getCommandSupport().fireCommandSent(command, message);
}
}
|
If there are any listeners, send them the command details.
@param command the command name
@param message the complete message, including command name
@since 3.0
|
fireCommandSent
|
java
|
alibaba/arthas
|
client/src/main/java/org/apache/commons/net/SocketClient.java
|
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/SocketClient.java
|
Apache-2.0
|
protected void createCommandSupport(){
__commandSupport = new ProtocolCommandSupport(this);
}
|
Create the CommandSupport instance if required
|
createCommandSupport
|
java
|
alibaba/arthas
|
client/src/main/java/org/apache/commons/net/SocketClient.java
|
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/SocketClient.java
|
Apache-2.0
|
protected ProtocolCommandSupport getCommandSupport() {
return __commandSupport;
}
|
Subclasses can override this if they need to provide their own
instance field for backwards compatibility.
@return the CommandSupport instance, may be {@code null}
@since 3.0
|
getCommandSupport
|
java
|
alibaba/arthas
|
client/src/main/java/org/apache/commons/net/SocketClient.java
|
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/SocketClient.java
|
Apache-2.0
|
public void setProxy(Proxy proxy) {
setSocketFactory(new DefaultSocketFactory(proxy));
connProxy = proxy;
}
|
Sets the proxy for use with all the connections.
The proxy is used for connections established after the
call to this method.
@param proxy the new proxy for connections.
@since 3.2
|
setProxy
|
java
|
alibaba/arthas
|
client/src/main/java/org/apache/commons/net/SocketClient.java
|
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/SocketClient.java
|
Apache-2.0
|
public Proxy getProxy() {
return connProxy;
}
|
Gets the proxy for use with all the connections.
@return the current proxy for connections.
|
getProxy
|
java
|
alibaba/arthas
|
client/src/main/java/org/apache/commons/net/SocketClient.java
|
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/SocketClient.java
|
Apache-2.0
|
@Deprecated
public String getCharsetName() {
return charset.name();
}
|
Gets the charset name.
@return the charset.
@since 3.3
@deprecated Since the code now requires Java 1.6 as a mininmum
|
getCharsetName
|
java
|
alibaba/arthas
|
client/src/main/java/org/apache/commons/net/SocketClient.java
|
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/SocketClient.java
|
Apache-2.0
|
@Override
public String getMessage()
{
return (msg + ": " + optionCode);
}
|
Gets the error message of ths exception.
<p>
@return the error message.
*
|
getMessage
|
java
|
alibaba/arthas
|
client/src/main/java/org/apache/commons/net/telnet/InvalidTelnetOptionException.java
|
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/InvalidTelnetOptionException.java
|
Apache-2.0
|
boolean _stateIsWill(int option)
{
return ((_options[option] & _WILL_MASK) != 0);
}
|
Looks for the state of the option.
@return returns true if a will has been acknowledged
@param option - option code to be looked up.
*
|
_stateIsWill
|
java
|
alibaba/arthas
|
client/src/main/java/org/apache/commons/net/telnet/Telnet.java
|
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/Telnet.java
|
Apache-2.0
|
boolean _stateIsWont(int option)
{
return !_stateIsWill(option);
}
|
Looks for the state of the option.
@return returns true if a wont has been acknowledged
@param option - option code to be looked up.
*
|
_stateIsWont
|
java
|
alibaba/arthas
|
client/src/main/java/org/apache/commons/net/telnet/Telnet.java
|
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/Telnet.java
|
Apache-2.0
|
boolean _stateIsDo(int option)
{
return ((_options[option] & _DO_MASK) != 0);
}
|
Looks for the state of the option.
@return returns true if a do has been acknowledged
@param option - option code to be looked up.
*
|
_stateIsDo
|
java
|
alibaba/arthas
|
client/src/main/java/org/apache/commons/net/telnet/Telnet.java
|
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/Telnet.java
|
Apache-2.0
|
boolean _stateIsDont(int option)
{
return !_stateIsDo(option);
}
|
Looks for the state of the option.
@return returns true if a dont has been acknowledged
@param option - option code to be looked up.
*
|
_stateIsDont
|
java
|
alibaba/arthas
|
client/src/main/java/org/apache/commons/net/telnet/Telnet.java
|
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/Telnet.java
|
Apache-2.0
|
boolean _requestedWill(int option)
{
return ((_options[option] & _REQUESTED_WILL_MASK) != 0);
}
|
Looks for the state of the option.
@return returns true if a will has been reuqested
@param option - option code to be looked up.
*
|
_requestedWill
|
java
|
alibaba/arthas
|
client/src/main/java/org/apache/commons/net/telnet/Telnet.java
|
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/Telnet.java
|
Apache-2.0
|
boolean _requestedWont(int option)
{
return !_requestedWill(option);
}
|
Looks for the state of the option.
@return returns true if a wont has been reuqested
@param option - option code to be looked up.
*
|
_requestedWont
|
java
|
alibaba/arthas
|
client/src/main/java/org/apache/commons/net/telnet/Telnet.java
|
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/Telnet.java
|
Apache-2.0
|
boolean _requestedDo(int option)
{
return ((_options[option] & _REQUESTED_DO_MASK) != 0);
}
|
Looks for the state of the option.
@return returns true if a do has been reuqested
@param option - option code to be looked up.
*
|
_requestedDo
|
java
|
alibaba/arthas
|
client/src/main/java/org/apache/commons/net/telnet/Telnet.java
|
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/Telnet.java
|
Apache-2.0
|
boolean _requestedDont(int option)
{
return !_requestedDo(option);
}
|
Looks for the state of the option.
@return returns true if a dont has been reuqested
@param option - option code to be looked up.
*
|
_requestedDont
|
java
|
alibaba/arthas
|
client/src/main/java/org/apache/commons/net/telnet/Telnet.java
|
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/Telnet.java
|
Apache-2.0
|
void _processCommand(int command)
{
if (debugoptions)
{
System.err.println("RECEIVED COMMAND: " + command);
}
if (__notifhand != null)
{
__notifhand.receivedNegotiation(
TelnetNotificationHandler.RECEIVED_COMMAND, command);
}
}
|
Processes a COMMAND.
@param command - option code to be set.
|
_processCommand
|
java
|
alibaba/arthas
|
client/src/main/java/org/apache/commons/net/telnet/Telnet.java
|
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/Telnet.java
|
Apache-2.0
|
void _processDo(int option) throws IOException
{
if (debugoptions)
{
System.err.println("RECEIVED DO: "
+ TelnetOption.getOption(option));
}
if (__notifhand != null)
{
__notifhand.receivedNegotiation(
TelnetNotificationHandler.RECEIVED_DO,
option);
}
boolean acceptNewState = false;
/* open TelnetOptionHandler functionality (start)*/
if (optionHandlers[option] != null)
{
acceptNewState = optionHandlers[option].getAcceptLocal();
}
else
{
/* open TelnetOptionHandler functionality (end)*/
/* TERMINAL-TYPE option (start)*/
if (option == TERMINAL_TYPE)
{
if ((terminalType != null) && (terminalType.length() > 0))
{
acceptNewState = true;
}
}
/* TERMINAL-TYPE option (end)*/
/* open TelnetOptionHandler functionality (start)*/
}
/* open TelnetOptionHandler functionality (end)*/
if (_willResponse[option] > 0)
{
--_willResponse[option];
if (_willResponse[option] > 0 && _stateIsWill(option))
{
--_willResponse[option];
}
}
if (_willResponse[option] == 0)
{
if (_requestedWont(option))
{
switch (option)
{
default:
break;
}
if (acceptNewState)
{
_setWantWill(option);
_sendWill(option);
}
else
{
++_willResponse[option];
_sendWont(option);
}
}
else
{
// Other end has acknowledged option.
switch (option)
{
default:
break;
}
}
}
_setWill(option);
}
|
Processes a DO request.
@param option - option code to be set.
@throws IOException - Exception in I/O.
|
_processDo
|
java
|
alibaba/arthas
|
client/src/main/java/org/apache/commons/net/telnet/Telnet.java
|
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/Telnet.java
|
Apache-2.0
|
void _processDont(int option) throws IOException
{
if (debugoptions)
{
System.err.println("RECEIVED DONT: "
+ TelnetOption.getOption(option));
}
if (__notifhand != null)
{
__notifhand.receivedNegotiation(
TelnetNotificationHandler.RECEIVED_DONT,
option);
}
if (_willResponse[option] > 0)
{
--_willResponse[option];
if (_willResponse[option] > 0 && _stateIsWont(option))
{
--_willResponse[option];
}
}
if (_willResponse[option] == 0 && _requestedWill(option))
{
switch (option)
{
default:
break;
}
/* FIX for a BUG in the negotiation (start)*/
if ((_stateIsWill(option)) || (_requestedWill(option)))
{
_sendWont(option);
}
_setWantWont(option);
/* FIX for a BUG in the negotiation (end)*/
}
_setWont(option);
}
|
Processes a DONT request.
@param option - option code to be set.
@throws IOException - Exception in I/O.
|
_processDont
|
java
|
alibaba/arthas
|
client/src/main/java/org/apache/commons/net/telnet/Telnet.java
|
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/Telnet.java
|
Apache-2.0
|
void _processWill(int option) throws IOException
{
if (debugoptions)
{
System.err.println("RECEIVED WILL: "
+ TelnetOption.getOption(option));
}
if (__notifhand != null)
{
__notifhand.receivedNegotiation(
TelnetNotificationHandler.RECEIVED_WILL,
option);
}
boolean acceptNewState = false;
/* open TelnetOptionHandler functionality (start)*/
if (optionHandlers[option] != null)
{
acceptNewState = optionHandlers[option].getAcceptRemote();
}
/* open TelnetOptionHandler functionality (end)*/
if (_doResponse[option] > 0)
{
--_doResponse[option];
if (_doResponse[option] > 0 && _stateIsDo(option))
{
--_doResponse[option];
}
}
if (_doResponse[option] == 0 && _requestedDont(option))
{
switch (option)
{
default:
break;
}
if (acceptNewState)
{
_setWantDo(option);
_sendDo(option);
}
else
{
++_doResponse[option];
_sendDont(option);
}
}
_setDo(option);
}
|
Processes a WILL request.
@param option - option code to be set.
@throws IOException - Exception in I/O.
|
_processWill
|
java
|
alibaba/arthas
|
client/src/main/java/org/apache/commons/net/telnet/Telnet.java
|
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/Telnet.java
|
Apache-2.0
|
void _processWont(int option) throws IOException
{
if (debugoptions)
{
System.err.println("RECEIVED WONT: "
+ TelnetOption.getOption(option));
}
if (__notifhand != null)
{
__notifhand.receivedNegotiation(
TelnetNotificationHandler.RECEIVED_WONT,
option);
}
if (_doResponse[option] > 0)
{
--_doResponse[option];
if (_doResponse[option] > 0 && _stateIsDont(option))
{
--_doResponse[option];
}
}
if (_doResponse[option] == 0 && _requestedDo(option))
{
switch (option)
{
default:
break;
}
/* FIX for a BUG in the negotiation (start)*/
if ((_stateIsDo(option)) || (_requestedDo(option)))
{
_sendDont(option);
}
_setWantDont(option);
/* FIX for a BUG in the negotiation (end)*/
}
_setDont(option);
}
|
Processes a WONT request.
@param option - option code to be set.
@throws IOException - Exception in I/O.
|
_processWont
|
java
|
alibaba/arthas
|
client/src/main/java/org/apache/commons/net/telnet/Telnet.java
|
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/Telnet.java
|
Apache-2.0
|
void _processSuboption(int suboption[], int suboptionLength)
throws IOException
{
if (debug)
{
System.err.println("PROCESS SUBOPTION.");
}
/* open TelnetOptionHandler functionality (start)*/
if (suboptionLength > 0)
{
if (optionHandlers[suboption[0]] != null)
{
int responseSuboption[] =
optionHandlers[suboption[0]].answerSubnegotiation(suboption,
suboptionLength);
_sendSubnegotiation(responseSuboption);
}
else
{
if (suboptionLength > 1)
{
if (debug)
{
for (int ii = 0; ii < suboptionLength; ii++)
{
System.err.println("SUB[" + ii + "]: "
+ suboption[ii]);
}
}
if ((suboption[0] == TERMINAL_TYPE)
&& (suboption[1] == TERMINAL_TYPE_SEND))
{
_sendTerminalType();
}
}
}
}
/* open TelnetOptionHandler functionality (end)*/
}
|
Processes a suboption negotiation.
@param suboption - subnegotiation data received
@param suboptionLength - length of data received
@throws IOException - Exception in I/O.
|
_processSuboption
|
java
|
alibaba/arthas
|
client/src/main/java/org/apache/commons/net/telnet/Telnet.java
|
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/Telnet.java
|
Apache-2.0
|
final synchronized void _sendTerminalType()
throws IOException
{
if (debug)
{
System.err.println("SEND TERMINAL-TYPE: " + terminalType);
}
if (terminalType != null)
{
_output_.write(_COMMAND_SB);
_output_.write(_COMMAND_IS);
_output_.write(terminalType.getBytes(getCharset()));
_output_.write(_COMMAND_SE);
_output_.flush();
}
}
|
Sends terminal type information.
@throws IOException - Exception in I/O.
*
|
_sendTerminalType
|
java
|
alibaba/arthas
|
client/src/main/java/org/apache/commons/net/telnet/Telnet.java
|
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/Telnet.java
|
Apache-2.0
|
final synchronized void _sendSubnegotiation(int subn[])
throws IOException
{
if (debug)
{
System.err.println("SEND SUBNEGOTIATION: ");
if (subn != null)
{
System.err.println(Arrays.toString(subn));
}
}
if (subn != null)
{
_output_.write(_COMMAND_SB);
// Note _output_ is buffered, so might as well simplify by writing single bytes
for (int element : subn)
{
byte b = (byte) element;
if (b == (byte) TelnetCommand.IAC) { // cast is necessary because IAC is outside the signed byte range
_output_.write(b); // double any IAC bytes
}
_output_.write(b);
}
_output_.write(_COMMAND_SE);
/* Code Section added for sending the negotiation ASAP (start)*/
_output_.flush();
/* Code Section added for sending the negotiation ASAP (end)*/
}
}
|
Manages subnegotiation for Terminal Type.
@param subn - subnegotiation data to be sent
@throws IOException - Exception in I/O.
|
_sendSubnegotiation
|
java
|
alibaba/arthas
|
client/src/main/java/org/apache/commons/net/telnet/Telnet.java
|
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/Telnet.java
|
Apache-2.0
|
final synchronized void _sendCommand(byte cmd) throws IOException
{
_output_.write(TelnetCommand.IAC);
_output_.write(cmd);
_output_.flush();
}
|
Sends a command, automatically adds IAC prefix and flushes the output.
@param cmd - command data to be sent
@throws IOException - Exception in I/O.
@since 3.0
|
_sendCommand
|
java
|
alibaba/arthas
|
client/src/main/java/org/apache/commons/net/telnet/Telnet.java
|
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/Telnet.java
|
Apache-2.0
|
final synchronized void _processAYTResponse()
{
if (!aytFlag)
{
synchronized (aytMonitor)
{
aytFlag = true;
aytMonitor.notifyAll();
}
}
}
|
Processes the response of an AYT
*
|
_processAYTResponse
|
java
|
alibaba/arthas
|
client/src/main/java/org/apache/commons/net/telnet/Telnet.java
|
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/Telnet.java
|
Apache-2.0
|
@Override
protected void _connectAction_() throws IOException
{
/* (start). BUGFIX: clean the option info for each connection*/
for (int ii = 0; ii < TelnetOption.MAX_OPTION_VALUE + 1; ii++)
{
_doResponse[ii] = 0;
_willResponse[ii] = 0;
_options[ii] = 0;
if (optionHandlers[ii] != null)
{
optionHandlers[ii].setDo(false);
optionHandlers[ii].setWill(false);
}
}
/* (end). BUGFIX: clean the option info for each connection*/
super._connectAction_();
_input_ = new BufferedInputStream(_input_);
_output_ = new BufferedOutputStream(_output_);
/* open TelnetOptionHandler functionality (start)*/
for (int ii = 0; ii < TelnetOption.MAX_OPTION_VALUE + 1; ii++)
{
if (optionHandlers[ii] != null)
{
if (optionHandlers[ii].getInitLocal())
{
_requestWill(optionHandlers[ii].getOptionCode());
}
if (optionHandlers[ii].getInitRemote())
{
_requestDo(optionHandlers[ii].getOptionCode());
}
}
}
/* open TelnetOptionHandler functionality (end)*/
}
|
Called upon connection.
@throws IOException - Exception in I/O.
*
|
_connectAction_
|
java
|
alibaba/arthas
|
client/src/main/java/org/apache/commons/net/telnet/Telnet.java
|
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/Telnet.java
|
Apache-2.0
|
final synchronized void _sendDo(int option)
throws IOException
{
if (debug || debugoptions)
{
System.err.println("DO: " + TelnetOption.getOption(option));
}
_output_.write(_COMMAND_DO);
_output_.write(option);
/* Code Section added for sending the negotiation ASAP (start)*/
_output_.flush();
/* Code Section added for sending the negotiation ASAP (end)*/
}
|
Sends a DO.
@param option - Option code.
@throws IOException - Exception in I/O.
|
_sendDo
|
java
|
alibaba/arthas
|
client/src/main/java/org/apache/commons/net/telnet/Telnet.java
|
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/Telnet.java
|
Apache-2.0
|
final synchronized void _requestDo(int option)
throws IOException
{
if ((_doResponse[option] == 0 && _stateIsDo(option))
|| _requestedDo(option))
{
return ;
}
_setWantDo(option);
++_doResponse[option];
_sendDo(option);
}
|
Requests a DO.
@param option - Option code.
@throws IOException - Exception in I/O.
|
_requestDo
|
java
|
alibaba/arthas
|
client/src/main/java/org/apache/commons/net/telnet/Telnet.java
|
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/Telnet.java
|
Apache-2.0
|
final synchronized void _sendDont(int option)
throws IOException
{
if (debug || debugoptions)
{
System.err.println("DONT: " + TelnetOption.getOption(option));
}
_output_.write(_COMMAND_DONT);
_output_.write(option);
/* Code Section added for sending the negotiation ASAP (start)*/
_output_.flush();
/* Code Section added for sending the negotiation ASAP (end)*/
}
|
Sends a DONT.
@param option - Option code.
@throws IOException - Exception in I/O.
|
_sendDont
|
java
|
alibaba/arthas
|
client/src/main/java/org/apache/commons/net/telnet/Telnet.java
|
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/Telnet.java
|
Apache-2.0
|
final synchronized void _requestDont(int option)
throws IOException
{
if ((_doResponse[option] == 0 && _stateIsDont(option))
|| _requestedDont(option))
{
return ;
}
_setWantDont(option);
++_doResponse[option];
_sendDont(option);
}
|
Requests a DONT.
@param option - Option code.
@throws IOException - Exception in I/O.
|
_requestDont
|
java
|
alibaba/arthas
|
client/src/main/java/org/apache/commons/net/telnet/Telnet.java
|
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/Telnet.java
|
Apache-2.0
|
final synchronized void _sendWill(int option)
throws IOException
{
if (debug || debugoptions)
{
System.err.println("WILL: " + TelnetOption.getOption(option));
}
_output_.write(_COMMAND_WILL);
_output_.write(option);
/* Code Section added for sending the negotiation ASAP (start)*/
_output_.flush();
/* Code Section added for sending the negotiation ASAP (end)*/
}
|
Sends a WILL.
@param option - Option code.
@throws IOException - Exception in I/O.
|
_sendWill
|
java
|
alibaba/arthas
|
client/src/main/java/org/apache/commons/net/telnet/Telnet.java
|
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/Telnet.java
|
Apache-2.0
|
final synchronized void _requestWill(int option)
throws IOException
{
if ((_willResponse[option] == 0 && _stateIsWill(option))
|| _requestedWill(option))
{
return ;
}
_setWantWill(option);
++_doResponse[option];
_sendWill(option);
}
|
Requests a WILL.
@param option - Option code.
@throws IOException - Exception in I/O.
|
_requestWill
|
java
|
alibaba/arthas
|
client/src/main/java/org/apache/commons/net/telnet/Telnet.java
|
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/Telnet.java
|
Apache-2.0
|
final synchronized void _sendWont(int option)
throws IOException
{
if (debug || debugoptions)
{
System.err.println("WONT: " + TelnetOption.getOption(option));
}
_output_.write(_COMMAND_WONT);
_output_.write(option);
/* Code Section added for sending the negotiation ASAP (start)*/
_output_.flush();
/* Code Section added for sending the negotiation ASAP (end)*/
}
|
Sends a WONT.
@param option - Option code.
@throws IOException - Exception in I/O.
|
_sendWont
|
java
|
alibaba/arthas
|
client/src/main/java/org/apache/commons/net/telnet/Telnet.java
|
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/Telnet.java
|
Apache-2.0
|
final synchronized void _requestWont(int option)
throws IOException
{
if ((_willResponse[option] == 0 && _stateIsWont(option))
|| _requestedWont(option))
{
return ;
}
_setWantWont(option);
++_doResponse[option];
_sendWont(option);
}
|
Requests a WONT.
@param option - Option code.
@throws IOException - Exception in I/O.
|
_requestWont
|
java
|
alibaba/arthas
|
client/src/main/java/org/apache/commons/net/telnet/Telnet.java
|
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/Telnet.java
|
Apache-2.0
|
final synchronized void _sendByte(int b)
throws IOException
{
_output_.write(b);
/* Code Section added for supporting spystreams (start)*/
_spyWrite(b);
/* Code Section added for supporting spystreams (end)*/
}
|
Sends a byte.
@param b - byte to send
@throws IOException - Exception in I/O.
|
_sendByte
|
java
|
alibaba/arthas
|
client/src/main/java/org/apache/commons/net/telnet/Telnet.java
|
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/Telnet.java
|
Apache-2.0
|
final boolean _sendAYT(long timeout)
throws IOException, IllegalArgumentException, InterruptedException
{
boolean retValue = false;
synchronized (aytMonitor)
{
synchronized (this)
{
aytFlag = false;
_output_.write(_COMMAND_AYT);
_output_.flush();
}
aytMonitor.wait(timeout);
if (!aytFlag)
{
retValue = false;
aytFlag = true;
}
else
{
retValue = true;
}
}
return (retValue);
}
|
Sends an Are You There sequence and waits for the result.
@param timeout - Time to wait for a response (millis.)
@throws IOException - Exception in I/O.
@throws IllegalArgumentException - Illegal argument
@throws InterruptedException - Interrupted during wait.
@return true if AYT received a response, false otherwise
|
_sendAYT
|
java
|
alibaba/arthas
|
client/src/main/java/org/apache/commons/net/telnet/Telnet.java
|
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/Telnet.java
|
Apache-2.0
|
void addOptionHandler(TelnetOptionHandler opthand)
throws InvalidTelnetOptionException, IOException
{
int optcode = opthand.getOptionCode();
if (TelnetOption.isValidOption(optcode))
{
if (optionHandlers[optcode] == null)
{
optionHandlers[optcode] = opthand;
if (isConnected())
{
if (opthand.getInitLocal())
{
_requestWill(optcode);
}
if (opthand.getInitRemote())
{
_requestDo(optcode);
}
}
}
else
{
throw (new InvalidTelnetOptionException(
"Already registered option", optcode));
}
}
else
{
throw (new InvalidTelnetOptionException(
"Invalid Option Code", optcode));
}
}
|
Registers a new TelnetOptionHandler for this telnet to use.
@param opthand - option handler to be registered.
@throws InvalidTelnetOptionException - The option code is invalid.
@throws IOException on error
|
addOptionHandler
|
java
|
alibaba/arthas
|
client/src/main/java/org/apache/commons/net/telnet/Telnet.java
|
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/Telnet.java
|
Apache-2.0
|
void deleteOptionHandler(int optcode)
throws InvalidTelnetOptionException, IOException
{
if (TelnetOption.isValidOption(optcode))
{
if (optionHandlers[optcode] == null)
{
throw (new InvalidTelnetOptionException(
"Unregistered option", optcode));
}
else
{
TelnetOptionHandler opthand = optionHandlers[optcode];
optionHandlers[optcode] = null;
if (opthand.getWill())
{
_requestWont(optcode);
}
if (opthand.getDo())
{
_requestDont(optcode);
}
}
}
else
{
throw (new InvalidTelnetOptionException(
"Invalid Option Code", optcode));
}
}
|
Unregisters a TelnetOptionHandler.
@param optcode - Code of the option to be unregistered.
@throws InvalidTelnetOptionException - The option code is invalid.
@throws IOException on error
|
deleteOptionHandler
|
java
|
alibaba/arthas
|
client/src/main/java/org/apache/commons/net/telnet/Telnet.java
|
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/Telnet.java
|
Apache-2.0
|
void _registerSpyStream(OutputStream spystream)
{
spyStream = spystream;
}
|
Registers an OutputStream for spying what's going on in
the Telnet session.
@param spystream - OutputStream on which session activity
will be echoed.
*
|
_registerSpyStream
|
java
|
alibaba/arthas
|
client/src/main/java/org/apache/commons/net/telnet/Telnet.java
|
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/Telnet.java
|
Apache-2.0
|
void _spyRead(int ch)
{
OutputStream spy = spyStream;
if (spy != null)
{
try
{
if (ch != '\r') // never write '\r' on its own
{
if (ch == '\n')
{
spy.write('\r'); // add '\r' before '\n'
}
spy.write(ch); // write original character
spy.flush();
}
}
catch (IOException e)
{
spyStream = null;
}
}
}
|
Sends a read char on the spy stream.
@param ch - character read from the session
*
|
_spyRead
|
java
|
alibaba/arthas
|
client/src/main/java/org/apache/commons/net/telnet/Telnet.java
|
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/Telnet.java
|
Apache-2.0
|
void _spyWrite(int ch)
{
if (!(_stateIsDo(TelnetOption.ECHO)
&& _requestedDo(TelnetOption.ECHO)))
{
OutputStream spy = spyStream;
if (spy != null)
{
try
{
spy.write(ch);
spy.flush();
}
catch (IOException e)
{
spyStream = null;
}
}
}
}
|
Sends a written char on the spy stream.
@param ch - character written to the session
*
|
_spyWrite
|
java
|
alibaba/arthas
|
client/src/main/java/org/apache/commons/net/telnet/Telnet.java
|
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/Telnet.java
|
Apache-2.0
|
@Override
protected void _connectAction_() throws IOException
{
super._connectAction_();
TelnetInputStream tmp = new TelnetInputStream(_input_, this, readerThread);
if(readerThread)
{
tmp._start();
}
// __input CANNOT refer to the TelnetInputStream. We run into
// blocking problems when some classes use TelnetInputStream, so
// we wrap it with a BufferedInputStream which we know is safe.
// This blocking behavior requires further investigation, but right
// now it looks like classes like InputStreamReader are not implemented
// in a safe manner.
__input = new BufferedInputStream(tmp);
__output = new TelnetOutputStream(this);
}
|
Handles special connection requirements.
@exception IOException If an error occurs during connection setup.
*
|
_connectAction_
|
java
|
alibaba/arthas
|
client/src/main/java/org/apache/commons/net/telnet/TelnetClient.java
|
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/TelnetClient.java
|
Apache-2.0
|
@Override
public void disconnect() throws IOException
{
if (__input != null) {
__input.close();
}
if (__output != null) {
__output.close();
}
super.disconnect();
}
|
Disconnects the telnet session, closing the input and output streams
as well as the socket. If you have references to the
input and output streams of the telnet connection, you should not
close them yourself, but rather call disconnect to properly close
the connection.
*
|
disconnect
|
java
|
alibaba/arthas
|
client/src/main/java/org/apache/commons/net/telnet/TelnetClient.java
|
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/TelnetClient.java
|
Apache-2.0
|
public OutputStream getOutputStream()
{
return __output;
}
|
Returns the telnet connection output stream. You should not close the
stream when you finish with it. Rather, you should call
{@link #disconnect disconnect }.
@return The telnet connection output stream.
*
|
getOutputStream
|
java
|
alibaba/arthas
|
client/src/main/java/org/apache/commons/net/telnet/TelnetClient.java
|
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/TelnetClient.java
|
Apache-2.0
|
public InputStream getInputStream()
{
return __input;
}
|
Returns the telnet connection input stream. You should not close the
stream when you finish with it. Rather, you should call
{@link #disconnect disconnect }.
@return The telnet connection input stream.
*
|
getInputStream
|
java
|
alibaba/arthas
|
client/src/main/java/org/apache/commons/net/telnet/TelnetClient.java
|
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/TelnetClient.java
|
Apache-2.0
|
public boolean getLocalOptionState(int option)
{
/* BUG (option active when not already acknowledged) (start)*/
return (_stateIsWill(option) && _requestedWill(option));
/* BUG (option active when not already acknowledged) (end)*/
}
|
Returns the state of the option on the local side.
@param option - Option to be checked.
@return The state of the option on the local side.
*
|
getLocalOptionState
|
java
|
alibaba/arthas
|
client/src/main/java/org/apache/commons/net/telnet/TelnetClient.java
|
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/TelnetClient.java
|
Apache-2.0
|
public boolean getRemoteOptionState(int option)
{
/* BUG (option active when not already acknowledged) (start)*/
return (_stateIsDo(option) && _requestedDo(option));
/* BUG (option active when not already acknowledged) (end)*/
}
|
Returns the state of the option on the remote side.
@param option - Option to be checked.
@return The state of the option on the remote side.
*
|
getRemoteOptionState
|
java
|
alibaba/arthas
|
client/src/main/java/org/apache/commons/net/telnet/TelnetClient.java
|
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/TelnetClient.java
|
Apache-2.0
|
public boolean sendAYT(long timeout)
throws IOException, IllegalArgumentException, InterruptedException
{
return (_sendAYT(timeout));
}
|
Sends an Are You There sequence and waits for the result.
@param timeout - Time to wait for a response (millis.)
@return true if AYT received a response, false otherwise
@throws InterruptedException on error
@throws IllegalArgumentException on error
@throws IOException on error
*
|
sendAYT
|
java
|
alibaba/arthas
|
client/src/main/java/org/apache/commons/net/telnet/TelnetClient.java
|
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/TelnetClient.java
|
Apache-2.0
|
public void sendSubnegotiation(int[] message)
throws IOException, IllegalArgumentException
{
if (message.length < 1) {
throw new IllegalArgumentException("zero length message");
}
_sendSubnegotiation(message);
}
|
Sends a protocol-specific subnegotiation message to the remote peer.
{@link TelnetClient} will add the IAC SB & IAC SE framing bytes;
the first byte in {@code message} should be the appropriate telnet
option code.
<p>
This method does not wait for any response. Subnegotiation messages
sent by the remote end can be handled by registering an approrpriate
{@link TelnetOptionHandler}.
</p>
@param message option code followed by subnegotiation payload
@throws IllegalArgumentException if {@code message} has length zero
@throws IOException if an I/O error occurs while writing the message
@since 3.0
*
|
sendSubnegotiation
|
java
|
alibaba/arthas
|
client/src/main/java/org/apache/commons/net/telnet/TelnetClient.java
|
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/TelnetClient.java
|
Apache-2.0
|
public void sendCommand(byte command)
throws IOException, IllegalArgumentException
{
_sendCommand(command);
}
|
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
@throws IllegalArgumentException on error
@since 3.0
*
|
sendCommand
|
java
|
alibaba/arthas
|
client/src/main/java/org/apache/commons/net/telnet/TelnetClient.java
|
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/TelnetClient.java
|
Apache-2.0
|
@Override
public void addOptionHandler(TelnetOptionHandler opthand)
throws InvalidTelnetOptionException, IOException
{
super.addOptionHandler(opthand);
}
|
Registers a new TelnetOptionHandler for this telnet client to use.
@param opthand - option handler to be registered.
@throws InvalidTelnetOptionException on error
@throws IOException on error
*
|
addOptionHandler
|
java
|
alibaba/arthas
|
client/src/main/java/org/apache/commons/net/telnet/TelnetClient.java
|
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/TelnetClient.java
|
Apache-2.0
|
@Override
public void deleteOptionHandler(int optcode)
throws InvalidTelnetOptionException, IOException
{
super.deleteOptionHandler(optcode);
}
|
Unregisters a TelnetOptionHandler.
@param optcode - Code of the option to be unregistered.
@throws InvalidTelnetOptionException on error
@throws IOException on error
*
|
deleteOptionHandler
|
java
|
alibaba/arthas
|
client/src/main/java/org/apache/commons/net/telnet/TelnetClient.java
|
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/TelnetClient.java
|
Apache-2.0
|
public void registerSpyStream(OutputStream spystream)
{
super._registerSpyStream(spystream);
}
|
Registers an OutputStream for spying what's going on in
the TelnetClient session.
@param spystream - OutputStream on which session activity
will be echoed.
*
|
registerSpyStream
|
java
|
alibaba/arthas
|
client/src/main/java/org/apache/commons/net/telnet/TelnetClient.java
|
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/TelnetClient.java
|
Apache-2.0
|
public void setReaderThread(boolean flag)
{
readerThread = flag;
}
|
Sets the status of the reader thread.
<p>
When enabled, a seaparate internal reader thread is created for new
connections to read incoming data as it arrives. This results in
immediate handling of option negotiation, notifications, etc.
(at least until the fixed-size internal buffer fills up).
Otherwise, no thread is created an all negotiation and option
handling is deferred until a read() is performed on the
{@link #getInputStream input stream}.
</p>
<p>
The reader thread must be enabled for {@link TelnetInputListener}
support.
</p>
<p>
When this method is invoked, the reader thread status will apply to all
subsequent connections; the current connection (if any) is not affected.
</p>
@param flag true to enable the reader thread, false to disable
@see #registerInputListener
*
|
setReaderThread
|
java
|
alibaba/arthas
|
client/src/main/java/org/apache/commons/net/telnet/TelnetClient.java
|
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/TelnetClient.java
|
Apache-2.0
|
public boolean getReaderThread()
{
return (readerThread);
}
|
Gets the status of the reader thread.
@return true if the reader thread is enabled, false otherwise
*
|
getReaderThread
|
java
|
alibaba/arthas
|
client/src/main/java/org/apache/commons/net/telnet/TelnetClient.java
|
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/TelnetClient.java
|
Apache-2.0
|
public synchronized void registerInputListener(TelnetInputListener listener)
{
this.inputListener = listener;
}
|
Register a listener to be notified when new incoming data is
available to be read on the {@link #getInputStream input stream}.
Only one listener is supported at a time.
<p>
More precisely, notifications are issued whenever the number of
bytes available for immediate reading (i.e., the value returned
by {@link InputStream#available}) transitions from zero to non-zero.
Note that (in general) multiple reads may be required to empty the
buffer and reset this notification, because incoming bytes are being
added to the internal buffer asynchronously.
</p>
<p>
Notifications are only supported when a {@link #setReaderThread
reader thread} is enabled for the connection.
</p>
@param listener listener to be registered; replaces any previous
@since 3.0
*
|
registerInputListener
|
java
|
alibaba/arthas
|
client/src/main/java/org/apache/commons/net/telnet/TelnetClient.java
|
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/TelnetClient.java
|
Apache-2.0
|
public static final String getCommand(int code)
{
return __commandString[__FIRST_COMMAND - code];
}
|
Returns the string representation of the telnet protocol command
corresponding to the given command code.
<p>
@param code The command code of the telnet protocol command.
@return The string representation of the telnet protocol command.
*
|
getCommand
|
java
|
alibaba/arthas
|
client/src/main/java/org/apache/commons/net/telnet/TelnetCommand.java
|
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/TelnetCommand.java
|
Apache-2.0
|
public static final boolean isValidCommand(int code)
{
return (code <= __FIRST_COMMAND && code >= __LAST_COMMAND);
}
|
Determines if a given command code is valid. Returns true if valid,
false if not.
<p>
@param code The command code to test.
@return True if the command code is valid, false if not.
|
isValidCommand
|
java
|
alibaba/arthas
|
client/src/main/java/org/apache/commons/net/telnet/TelnetCommand.java
|
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/TelnetCommand.java
|
Apache-2.0
|
@Override
public int read(byte buffer[]) throws IOException
{
return read(buffer, 0, buffer.length);
}
|
Reads the next number of bytes from the stream into an array and
returns the number of bytes read. Returns -1 if the end of the
stream has been reached.
<p>
@param buffer The byte array in which to store the data.
@return The number of bytes read. Returns -1 if the
end of the message has been reached.
@exception IOException If an error occurs in reading the underlying
stream.
*
|
read
|
java
|
alibaba/arthas
|
client/src/main/java/org/apache/commons/net/telnet/TelnetInputStream.java
|
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/TelnetInputStream.java
|
Apache-2.0
|
@Override
public int read(byte buffer[], int offset, int length) throws IOException
{
int ch, off;
if (length < 1) {
return 0;
}
// Critical section because run() may change __bytesAvailable
synchronized (__queue)
{
if (length > __bytesAvailable) {
length = __bytesAvailable;
}
}
if ((ch = read()) == EOF) {
return EOF;
}
off = offset;
do
{
buffer[offset++] = (byte)ch;
}
while (--length > 0 && (ch = read()) != EOF);
//__client._spyRead(buffer, off, offset - off);
return (offset - off);
}
|
Reads the next number of bytes from the stream into an array and returns
the number of bytes read. Returns -1 if the end of the
message has been reached. The characters are stored in the array
starting from the given offset and up to the length specified.
<p>
@param buffer The byte array in which to store the data.
@param offset The offset into the array at which to start storing data.
@param length The number of bytes to read.
@return The number of bytes read. Returns -1 if the
end of the stream has been reached.
@exception IOException If an error occurs while reading the underlying
stream.
*
|
read
|
java
|
alibaba/arthas
|
client/src/main/java/org/apache/commons/net/telnet/TelnetInputStream.java
|
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/TelnetInputStream.java
|
Apache-2.0
|
public static final String getOption(int code)
{
if(__optionString[code].length() == 0)
{
return "UNASSIGNED";
}
else
{
return __optionString[code];
}
}
|
Returns the string representation of the telnet protocol option
corresponding to the given option code.
@param code The option code of the telnet protocol option
@return The string representation of the telnet protocol option.
*
|
getOption
|
java
|
alibaba/arthas
|
client/src/main/java/org/apache/commons/net/telnet/TelnetOption.java
|
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/TelnetOption.java
|
Apache-2.0
|
public static final boolean isValidOption(int code)
{
return (code <= __LAST_OPTION);
}
|
Determines if a given option code is valid. Returns true if valid,
false if not.
@param code The option code to test.
@return True if the option code is valid, false if not.
|
isValidOption
|
java
|
alibaba/arthas
|
client/src/main/java/org/apache/commons/net/telnet/TelnetOption.java
|
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/TelnetOption.java
|
Apache-2.0
|
public int getOptionCode()
{
return (optionCode);
}
|
Returns the option code for this option.
<p>
@return Option code.
*
|
getOptionCode
|
java
|
alibaba/arthas
|
client/src/main/java/org/apache/commons/net/telnet/TelnetOptionHandler.java
|
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/TelnetOptionHandler.java
|
Apache-2.0
|
public boolean getAcceptLocal()
{
return (acceptLocal);
}
|
Returns a boolean indicating whether to accept a DO
request coming from the other end.
<p>
@return true if a DO request shall be accepted.
*
|
getAcceptLocal
|
java
|
alibaba/arthas
|
client/src/main/java/org/apache/commons/net/telnet/TelnetOptionHandler.java
|
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/TelnetOptionHandler.java
|
Apache-2.0
|
public boolean getAcceptRemote()
{
return (acceptRemote);
}
|
Returns a boolean indicating whether to accept a WILL
request coming from the other end.
<p>
@return true if a WILL request shall be accepted.
*
|
getAcceptRemote
|
java
|
alibaba/arthas
|
client/src/main/java/org/apache/commons/net/telnet/TelnetOptionHandler.java
|
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/TelnetOptionHandler.java
|
Apache-2.0
|
public void setAcceptLocal(boolean accept)
{
acceptLocal = accept;
}
|
Set behaviour of the option for DO requests coming from
the other end.
<p>
@param accept - if true, subsequent DO requests will be accepted.
*
|
setAcceptLocal
|
java
|
alibaba/arthas
|
client/src/main/java/org/apache/commons/net/telnet/TelnetOptionHandler.java
|
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/TelnetOptionHandler.java
|
Apache-2.0
|
public void setAcceptRemote(boolean accept)
{
acceptRemote = accept;
}
|
Set behaviour of the option for WILL requests coming from
the other end.
<p>
@param accept - if true, subsequent WILL requests will be accepted.
*
|
setAcceptRemote
|
java
|
alibaba/arthas
|
client/src/main/java/org/apache/commons/net/telnet/TelnetOptionHandler.java
|
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/TelnetOptionHandler.java
|
Apache-2.0
|
public boolean getInitLocal()
{
return (initialLocal);
}
|
Returns a boolean indicating whether to send a WILL request
to the other end upon connection.
<p>
@return true if a WILL request shall be sent upon connection.
*
|
getInitLocal
|
java
|
alibaba/arthas
|
client/src/main/java/org/apache/commons/net/telnet/TelnetOptionHandler.java
|
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/TelnetOptionHandler.java
|
Apache-2.0
|
public boolean getInitRemote()
{
return (initialRemote);
}
|
Returns a boolean indicating whether to send a DO request
to the other end upon connection.
<p>
@return true if a DO request shall be sent upon connection.
*
|
getInitRemote
|
java
|
alibaba/arthas
|
client/src/main/java/org/apache/commons/net/telnet/TelnetOptionHandler.java
|
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/TelnetOptionHandler.java
|
Apache-2.0
|
public void setInitLocal(boolean init)
{
initialLocal = init;
}
|
Tells this option whether to send a WILL request upon connection.
<p>
@param init - if true, a WILL request will be sent upon subsequent
connections.
*
|
setInitLocal
|
java
|
alibaba/arthas
|
client/src/main/java/org/apache/commons/net/telnet/TelnetOptionHandler.java
|
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/TelnetOptionHandler.java
|
Apache-2.0
|
public void setInitRemote(boolean init)
{
initialRemote = init;
}
|
Tells this option whether to send a DO request upon connection.
<p>
@param init - if true, a DO request will be sent upon subsequent
connections.
*
|
setInitRemote
|
java
|
alibaba/arthas
|
client/src/main/java/org/apache/commons/net/telnet/TelnetOptionHandler.java
|
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/TelnetOptionHandler.java
|
Apache-2.0
|
public int[] answerSubnegotiation(int suboptionData[], int suboptionLength) {
return null;
}
|
Method called upon reception of a subnegotiation for this option
coming from the other end.
<p>
This implementation returns null, and
must be overridden by the actual TelnetOptionHandler to specify
which response must be sent for the subnegotiation request.
<p>
@param suboptionData - the sequence received, without IAC SB & IAC SE
@param suboptionLength - the length of data in suboption_data
<p>
@return response to be sent to the subnegotiation sequence. TelnetClient
will add IAC SB & IAC SE. null means no response
*
|
answerSubnegotiation
|
java
|
alibaba/arthas
|
client/src/main/java/org/apache/commons/net/telnet/TelnetOptionHandler.java
|
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/TelnetOptionHandler.java
|
Apache-2.0
|
public int[] startSubnegotiationLocal() {
return null;
}
|
This method is invoked whenever this option is acknowledged active on
the local end (TelnetClient sent a WILL, remote side sent a DO).
The method is used to specify a subnegotiation sequence that will be
sent by TelnetClient when the option is activated.
<p>
This implementation returns null, and must be overridden by
the actual TelnetOptionHandler to specify
which response must be sent for the subnegotiation request.
@return subnegotiation sequence to be sent by TelnetClient. TelnetClient
will add IAC SB & IAC SE. null means no subnegotiation.
*
|
startSubnegotiationLocal
|
java
|
alibaba/arthas
|
client/src/main/java/org/apache/commons/net/telnet/TelnetOptionHandler.java
|
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/TelnetOptionHandler.java
|
Apache-2.0
|
public int[] startSubnegotiationRemote() {
return null;
}
|
This method is invoked whenever this option is acknowledged active on
the remote end (TelnetClient sent a DO, remote side sent a WILL).
The method is used to specify a subnegotiation sequence that will be
sent by TelnetClient when the option is activated.
<p>
This implementation returns null, and must be overridden by
the actual TelnetOptionHandler to specify
which response must be sent for the subnegotiation request.
@return subnegotiation sequence to be sent by TelnetClient. TelnetClient
will add IAC SB & IAC SE. null means no subnegotiation.
*
|
startSubnegotiationRemote
|
java
|
alibaba/arthas
|
client/src/main/java/org/apache/commons/net/telnet/TelnetOptionHandler.java
|
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/TelnetOptionHandler.java
|
Apache-2.0
|
boolean getWill()
{
return willFlag;
}
|
Returns a boolean indicating whether a WILL request sent to the other
side has been acknowledged.
<p>
@return true if a WILL sent to the other side has been acknowledged.
*
|
getWill
|
java
|
alibaba/arthas
|
client/src/main/java/org/apache/commons/net/telnet/TelnetOptionHandler.java
|
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/TelnetOptionHandler.java
|
Apache-2.0
|
void setWill(boolean state)
{
willFlag = state;
}
|
Tells this option whether a WILL request sent to the other
side has been acknowledged (invoked by TelnetClient).
<p>
@param state - if true, a WILL request has been acknowledged.
*
|
setWill
|
java
|
alibaba/arthas
|
client/src/main/java/org/apache/commons/net/telnet/TelnetOptionHandler.java
|
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/TelnetOptionHandler.java
|
Apache-2.0
|
boolean getDo()
{
return doFlag;
}
|
Returns a boolean indicating whether a DO request sent to the other
side has been acknowledged.
<p>
@return true if a DO sent to the other side has been acknowledged.
*
|
getDo
|
java
|
alibaba/arthas
|
client/src/main/java/org/apache/commons/net/telnet/TelnetOptionHandler.java
|
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/TelnetOptionHandler.java
|
Apache-2.0
|
void setDo(boolean state)
{
doFlag = state;
}
|
Tells this option whether a DO request sent to the other
side has been acknowledged (invoked by TelnetClient).
<p>
@param state - if true, a DO request has been acknowledged.
*
|
setDo
|
java
|
alibaba/arthas
|
client/src/main/java/org/apache/commons/net/telnet/TelnetOptionHandler.java
|
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/TelnetOptionHandler.java
|
Apache-2.0
|
@Override
public void write(int ch) throws IOException
{
synchronized (__client)
{
ch &= 0xff;
if (__client._requestedWont(TelnetOption.BINARY)) // i.e. ASCII
{
if (__lastWasCR)
{
if (__convertCRtoCRLF)
{
__client._sendByte('\n');
if (ch == '\n') // i.e. was CRLF anyway
{
__lastWasCR = false;
return ;
}
} // __convertCRtoCRLF
else if (ch != '\n')
{
__client._sendByte('\0'); // RFC854 requires CR NUL for bare CR
}
}
switch (ch)
{
case '\r':
__client._sendByte('\r');
__lastWasCR = true;
break;
case '\n':
if (!__lastWasCR) { // convert LF to CRLF
__client._sendByte('\r');
}
__client._sendByte(ch);
__lastWasCR = false;
break;
case TelnetCommand.IAC:
__client._sendByte(TelnetCommand.IAC);
__client._sendByte(TelnetCommand.IAC);
__lastWasCR = false;
break;
default:
__client._sendByte(ch);
__lastWasCR = false;
break;
}
} // end ASCII
else if (ch == TelnetCommand.IAC)
{
__client._sendByte(ch);
__client._sendByte(TelnetCommand.IAC);
} else {
__client._sendByte(ch);
}
}
}
|
Writes a byte to the stream.
<p>
@param ch The byte to write.
@exception IOException If an error occurs while writing to the underlying
stream.
*
|
write
|
java
|
alibaba/arthas
|
client/src/main/java/org/apache/commons/net/telnet/TelnetOutputStream.java
|
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/TelnetOutputStream.java
|
Apache-2.0
|
@Override
public void write(byte buffer[]) throws IOException
{
write(buffer, 0, buffer.length);
}
|
Writes a byte array to the stream.
<p>
@param buffer The byte array to write.
@exception IOException If an error occurs while writing to the underlying
stream.
*
|
write
|
java
|
alibaba/arthas
|
client/src/main/java/org/apache/commons/net/telnet/TelnetOutputStream.java
|
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/TelnetOutputStream.java
|
Apache-2.0
|
@Override
public void write(byte buffer[], int offset, int length) throws IOException
{
synchronized (__client)
{
while (length-- > 0) {
write(buffer[offset++]);
}
}
}
|
Writes a number of bytes from a byte array to the stream starting from
a given offset.
<p>
@param buffer The byte array to write.
@param offset The offset into the array at which to start copying data.
@param length The number of bytes to write.
@exception IOException If an error occurs while writing to the underlying
stream.
*
|
write
|
java
|
alibaba/arthas
|
client/src/main/java/org/apache/commons/net/telnet/TelnetOutputStream.java
|
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/TelnetOutputStream.java
|
Apache-2.0
|
@Override
public int[] answerSubnegotiation(int suboptionData[], int suboptionLength)
{
if ((suboptionData != null) && (suboptionLength > 1)
&& (termType != null))
{
if ((suboptionData[0] == TERMINAL_TYPE)
&& (suboptionData[1] == TERMINAL_TYPE_SEND))
{
int response[] = new int[termType.length() + 2];
response[0] = TERMINAL_TYPE;
response[1] = TERMINAL_TYPE_IS;
for (int ii = 0; ii < termType.length(); ii++)
{
response[ii + 2] = termType.charAt(ii);
}
return response;
}
}
return null;
}
|
Implements the abstract method of TelnetOptionHandler.
<p>
@param suboptionData - the sequence received, without IAC SB & IAC SE
@param suboptionLength - the length of data in suboption_data
<p>
@return terminal type information
*
|
answerSubnegotiation
|
java
|
alibaba/arthas
|
client/src/main/java/org/apache/commons/net/telnet/TerminalTypeOptionHandler.java
|
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/TerminalTypeOptionHandler.java
|
Apache-2.0
|
@Override
public int[] startSubnegotiationLocal()
{
int nCompoundWindowSize = m_nWidth * 0x10000 + m_nHeight;
int nResponseSize = 5;
int nIndex;
int nShift;
int nTurnedOnBits;
if ((m_nWidth % 0x100) == 0xFF) {
nResponseSize += 1;
}
if ((m_nWidth / 0x100) == 0xFF) {
nResponseSize += 1;
}
if ((m_nHeight % 0x100) == 0xFF) {
nResponseSize += 1;
}
if ((m_nHeight / 0x100) == 0xFF) {
nResponseSize += 1;
}
//
// allocate response array
//
int response[] = new int[nResponseSize];
//
// Build response array.
// ---------------------
// 1. put option name.
// 2. loop through Window size and fill the values,
// 3. duplicate 'ff' if needed.
//
response[0] = WINDOW_SIZE; // 1 //
for ( // 2 //
nIndex=1, nShift = 24;
nIndex < nResponseSize;
nIndex++, nShift -=8
) {
nTurnedOnBits = 0xFF;
nTurnedOnBits <<= nShift;
response[nIndex] = (nCompoundWindowSize & nTurnedOnBits) >>> nShift;
if (response[nIndex] == 0xff) { // 3 //
nIndex++;
response[nIndex] = 0xff;
}
}
return response;
}
|
Implements the abstract method of TelnetOptionHandler.
This will send the client Height and Width to the server.
<p>
@return array to send to remote system
*
|
startSubnegotiationLocal
|
java
|
alibaba/arthas
|
client/src/main/java/org/apache/commons/net/telnet/WindowSizeOptionHandler.java
|
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/WindowSizeOptionHandler.java
|
Apache-2.0
|
@Override
public Iterator<EventListener> iterator() {
return __listeners.iterator();
}
|
Return an {@link Iterator} for the {@link EventListener} instances.
@return an {@link Iterator} for the {@link EventListener} instances
@since 2.0
TODO Check that this is a good defensive strategy
|
iterator
|
java
|
alibaba/arthas
|
client/src/main/java/org/apache/commons/net/util/ListenerList.java
|
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/util/ListenerList.java
|
Apache-2.0
|
public static void writeByteArrayToFile(final File file, final byte[] data) throws IOException {
writeByteArrayToFile(file, data, false);
}
|
Writes a byte array to a file creating the file if it does not exist.
<p>
NOTE: As from v1.3, the parent directories of the file will be created if
they do not exist.
@param file the file to write to
@param data the content to write to the file
@throws IOException in case of an I/O error
@since 1.1
|
writeByteArrayToFile
|
java
|
alibaba/arthas
|
common/src/main/java/com/taobao/arthas/common/FileUtils.java
|
https://github.com/alibaba/arthas/blob/master/common/src/main/java/com/taobao/arthas/common/FileUtils.java
|
Apache-2.0
|
public static void writeByteArrayToFile(final File file, final byte[] data, final boolean append)
throws IOException {
writeByteArrayToFile(file, data, 0, data.length, append);
}
|
Writes a byte array to a file creating the file if it does not exist.
@param file the file to write to
@param data the content to write to the file
@param append if {@code true}, then bytes will be added to the end of the
file rather than overwriting
@throws IOException in case of an I/O error
@since 2.1
|
writeByteArrayToFile
|
java
|
alibaba/arthas
|
common/src/main/java/com/taobao/arthas/common/FileUtils.java
|
https://github.com/alibaba/arthas/blob/master/common/src/main/java/com/taobao/arthas/common/FileUtils.java
|
Apache-2.0
|
public static void writeByteArrayToFile(final File file, final byte[] data, final int off, final int len)
throws IOException {
writeByteArrayToFile(file, data, off, len, false);
}
|
Writes {@code len} bytes from the specified byte array starting at offset
{@code off} to a file, creating the file if it does not exist.
@param file the file to write to
@param data the content to write to the file
@param off the start offset in the data
@param len the number of bytes to write
@throws IOException in case of an I/O error
@since 2.5
|
writeByteArrayToFile
|
java
|
alibaba/arthas
|
common/src/main/java/com/taobao/arthas/common/FileUtils.java
|
https://github.com/alibaba/arthas/blob/master/common/src/main/java/com/taobao/arthas/common/FileUtils.java
|
Apache-2.0
|
public static void writeByteArrayToFile(final File file, final byte[] data, final int off, final int len,
final boolean append) throws IOException {
FileOutputStream out = null;
try {
out = openOutputStream(file, append);
out.write(data, off, len);
} finally {
IOUtils.close(out);
}
}
|
Writes {@code len} bytes from the specified byte array starting at offset
{@code off} to a file, creating the file if it does not exist.
@param file the file to write to
@param data the content to write to the file
@param off the start offset in the data
@param len the number of bytes to write
@param append if {@code true}, then bytes will be added to the end of the
file rather than overwriting
@throws IOException in case of an I/O error
@since 2.5
|
writeByteArrayToFile
|
java
|
alibaba/arthas
|
common/src/main/java/com/taobao/arthas/common/FileUtils.java
|
https://github.com/alibaba/arthas/blob/master/common/src/main/java/com/taobao/arthas/common/FileUtils.java
|
Apache-2.0
|
public static FileOutputStream openOutputStream(final File file, final boolean append) throws IOException {
if (file.exists()) {
if (file.isDirectory()) {
throw new IOException("File '" + file + "' exists but is a directory");
}
if (!file.canWrite()) {
throw new IOException("File '" + file + "' cannot be written to");
}
} else {
final File parent = file.getParentFile();
if (parent != null) {
if (!parent.mkdirs() && !parent.isDirectory()) {
throw new IOException("Directory '" + parent + "' could not be created");
}
}
}
return new FileOutputStream(file, append);
}
|
Opens a {@link FileOutputStream} for the specified file, checking and
creating the parent directory if it does not exist.
<p>
At the end of the method either the stream will be successfully opened, or an
exception will have been thrown.
<p>
The parent directory will be created if it does not exist. The file will be
created if it does not exist. An exception is thrown if the file object
exists but is a directory. An exception is thrown if the file exists but
cannot be written to. An exception is thrown if the parent directory cannot
be created.
@param file the file to open for output, must not be {@code null}
@param append if {@code true}, then bytes will be added to the end of the
file rather than overwriting
@return a new {@link FileOutputStream} for the specified file
@throws IOException if the file object is a directory
@throws IOException if the file cannot be written to
@throws IOException if a parent directory needs creating but that fails
@since 2.1
|
openOutputStream
|
java
|
alibaba/arthas
|
common/src/main/java/com/taobao/arthas/common/FileUtils.java
|
https://github.com/alibaba/arthas/blob/master/common/src/main/java/com/taobao/arthas/common/FileUtils.java
|
Apache-2.0
|
public static byte[] readFileToByteArray(final File file) throws IOException {
InputStream in = null;
try {
in = new FileInputStream(file);
return IOUtils.getBytes(in);
} finally {
IOUtils.close(in);
}
}
|
Reads the contents of a file into a byte array.
The file is always closed.
@param file the file to read, must not be {@code null}
@return the file contents, never {@code null}
@throws IOException in case of an I/O error
@since 1.1
|
readFileToByteArray
|
java
|
alibaba/arthas
|
common/src/main/java/com/taobao/arthas/common/FileUtils.java
|
https://github.com/alibaba/arthas/blob/master/common/src/main/java/com/taobao/arthas/common/FileUtils.java
|
Apache-2.0
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.