|
![]() |
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--ipworks.Telnet
The Telnet class is used to communicate with servers implementing the Telnet protocol.
The Telnet class provides a simple interface to Telnet communications as specified by RFC 854. It allows sending of Telnet command codes to remote Telnet servers and it scans the input data for Telnet commands. Appropriate events are fired for received commands.
The connection interface is very similar to that of IPPort. The same properties and events are used for sending and receiving normal data, and the same property set is used for setting properties of the connection. The Telnet class adds a number of properties like Command , DoOption , etc. which allow sending of Telnet commands to the other end. The respective events ( Command , Do , etc.) are fired when the corresponding Telnet commands are received.
Constructor Summary | |
Telnet()
|
Method Summary | |
void |
addTelnetEventListener(TelnetEventListener l)
|
void |
fireCommand(int commandCode)
Fired when a Telnet command comes from the Telnet server. |
void |
fireConnected(int statusCode,
java.lang.String description)
Fired immediately after a connection completes (or fails). |
void |
fireDataIn(byte[] text)
Fired when characters are received from the remote host. |
void |
fireDisconnected(int statusCode,
java.lang.String description)
Fired when a connection is closed. |
void |
fireDoDo(int optionCode)
Fired when a Telnet DO OPTION command comes from the Telnet server. |
void |
fireDont(int optionCode)
Fired when a Telnet DONT OPTION command comes from the Telnet server. |
void |
fireError(int errorCode,
java.lang.String description)
Information about errors during data delivery. |
void |
fireReadyToSend()
Fired when the component is ready to send data. |
void |
fireSubOption(byte[] subOption)
Fired when a Telnet suboption command comes from the Telnet server. |
void |
fireWill(int optionCode)
Fired when a Telnet WILL OPTION command comes from the Telnet server. |
void |
fireWont(int optionCode)
Fired when a Telnet WONT OPTION command comes from the Telnet server. |
int |
getBytesSent()
The number of bytes actually sent after an assignment to DataToSend . |
java.lang.String |
getLocalHost()
The name of the local host. |
int |
getLocalPort()
The TCP port in the local host where IPPort binds. |
java.lang.String |
getRemoteHost()
The address of the RemoteHost. |
int |
getRemotePort()
The Telnet port in the remote host (default is 23). |
boolean |
isAcceptData()
Enables or disables data reception (the DataIn event). |
boolean |
isConnected()
Triggers a connection or disconnection. |
boolean |
isKeepAlive()
When True, KEEPALIVE packets are enabled (for long connections). |
boolean |
isLinger()
When set to True, connections are terminated gracefully. |
void |
removeTelnetEventListener(TelnetEventListener l)
|
void |
setAcceptData(boolean acceptData)
Enables or disables data reception (the DataIn event). |
void |
setCommand(int command)
A single character Telnet command code to be sent to the server. |
void |
setConnected(boolean connected)
Triggers a connection or disconnection. |
void |
setDataToSend(byte[] dataToSend)
A string of data to be sent to the remote host. |
void |
setDontOption(int dontOption)
A single character Telnet option code to be sent to the server with the Telnet DONT command. |
void |
setDoOption(int doOption)
A single character Telnet option code to be sent to the server with the Telnet DO command. |
void |
setDoSubOption(byte[] doSubOption)
A Telnet suboption to send to the server with the suboption command. |
void |
setKeepAlive(boolean keepAlive)
When True, KEEPALIVE packets are enabled (for long connections). |
void |
setLinger(boolean linger)
When set to True, connections are terminated gracefully. |
void |
setLocalPort(int localPort)
The TCP port in the local host where IPPort binds. |
void |
setRemoteHost(java.lang.String remoteHost)
The address of the RemoteHost. |
void |
setRemotePort(int remotePort)
The Telnet port in the remote host (default is 23). |
void |
setUrgentData(byte[] urgentData)
A string of data to be sent urgently (out-of-band) to the remote host. |
void |
setWillOption(int willOption)
A single character Telnet option code to be sent to the server with the Telnet WILL command. |
void |
setWontOption(int wontOption)
A single character Telnet option code to be sent to the server with the Telnet WONT command. |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Constructor Detail |
public Telnet()
Method Detail |
public boolean isAcceptData()
public void setAcceptData(boolean acceptData) throws IPWorksException
public int getBytesSent()
public void setCommand(int command) throws IPWorksException
public boolean isConnected()
Setting Connected to False closes the connection. How and when the connection is closed is controlled by the Linger property.
public void setConnected(boolean connected) throws IPWorksException
Setting Connected to False closes the connection. How and when the connection is closed is controlled by the Linger property.
public void setDataToSend(byte[] dataToSend) throws IPWorksException
If you are sending data to the remote host faster than it can process it, or faster than the network's bandwidth allows, the outgoing queue might fill up. When this happens, DataToSend If 0 bytes were sent, then you can wait for the ReadyToSend event before attempting to send data again. (However, please note that ReadyToSend is not fired when part of the data is successfully sent).
public void setDontOption(int dontOption) throws IPWorksException
public void setDoOption(int doOption) throws IPWorksException
public void setDoSubOption(byte[] doSubOption) throws IPWorksException
You don't need to specify the suboption start and suboption end codes. Those are appended automatically by the class. For example, to send a terminal type suboption to request setting the terminal type to 'vt100', you must do the following:
public boolean isKeepAlive()
Please note that Winsock implementations are not required to support SO_KEEPALIVE.
public void setKeepAlive(boolean keepAlive) throws IPWorksException
Please note that Winsock implementations are not required to support SO_KEEPALIVE.
public boolean isLinger()
The default behavior (which is also the default mode for Winsock stream sockets) might result in an indefinite delay in closing the connection. Although the class returns control immediately, Winsock might indefinitely hold system resources until all pending data are sent (even after your application closes). This means that valuable system resources might be wasted.
Setting Linger to False forces an immediate disconnection. If you know that the other side has received all the data you had sent (by a client acknowledgment, for example), setting Linger to False might be the appropriate course of action.
public void setLinger(boolean linger) throws IPWorksException
The default behavior (which is also the default mode for Winsock stream sockets) might result in an indefinite delay in closing the connection. Although the class returns control immediately, Winsock might indefinitely hold system resources until all pending data are sent (even after your application closes). This means that valuable system resources might be wasted.
Setting Linger to False forces an immediate disconnection. If you know that the other side has received all the data you had sent (by a client acknowledgment, for example), setting Linger to False might be the appropriate course of action.
public java.lang.String getLocalHost()
If the class is connected, the LocalHost property shows the IP address of the interface through which the connection is made in internet dotted format (aaa.bbb.ccc.ddd). In most cases, this is the address of the local host, except for multihomed hosts (machines with more than one IP interface).
public int getLocalPort()
Setting it to 0 (default) enables Winsock to choose a port at random. The chosen port will be shown by the LocalPort property after the connection is established.
LocalPort cannot be changed once a connection is made. Any attempt to set the LocalPort property when a connection is active will generate an error.
The LocalPort property is useful when trying to connect to services that require a trusted port in the client side.
public void setLocalPort(int localPort) throws IPWorksException
Setting it to 0 (default) enables Winsock to choose a port at random. The chosen port will be shown by the LocalPort property after the connection is established.
LocalPort cannot be changed once a connection is made. Any attempt to set the LocalPort property when a connection is active will generate an error.
The LocalPort property is useful when trying to connect to services that require a trusted port in the client side.
public java.lang.String getRemoteHost()
If the RemoteHost property is set to a Domain Name, a DNS request is initiated and upon successful termination of the request, the RemoteHost property is set to the corresponding address. If the search is not successful, an error is returned.
public void setRemoteHost(java.lang.String remoteHost) throws IPWorksException
If the RemoteHost property is set to a Domain Name, a DNS request is initiated and upon successful termination of the request, the RemoteHost property is set to the corresponding address. If the search is not successful, an error is returned.
public int getRemotePort()
public void setRemotePort(int remotePort) throws IPWorksException
public void setUrgentData(byte[] urgentData) throws IPWorksException
public void setWillOption(int willOption) throws IPWorksException
public void setWontOption(int wontOption) throws IPWorksException
public void fireCommand(int commandCode)
TelnetCommandEvent
public void fireConnected(int statusCode, java.lang.String description)
TelnetConnectedEvent
public void fireDataIn(byte[] text)
TelnetDataInEvent
public void fireDisconnected(int statusCode, java.lang.String description)
TelnetDisconnectedEvent
public void fireDoDo(int optionCode)
TelnetDoDoEvent
public void fireDont(int optionCode)
TelnetDontEvent
public void fireError(int errorCode, java.lang.String description)
TelnetErrorEvent
public void fireReadyToSend()
TelnetReadyToSendEvent
public void fireSubOption(byte[] subOption)
TelnetSubOptionEvent
public void fireWill(int optionCode)
TelnetWillEvent
public void fireWont(int optionCode)
TelnetWontEvent
public void addTelnetEventListener(TelnetEventListener l) throws java.util.TooManyListenersException
public void removeTelnetEventListener(TelnetEventListener l)
|
![]() |
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |