public class TcpProtocol extends Protocol
This class is used for sending packets over a TCP connection to the Console.
It is used when the 'tcp' protocol is specified in the SmartInspect.setConnections(java.lang.String) connections string.
Please see the isValidOption method for a list of available protocol options.
Thread Safety: The public members of this class are threadsafe.
| Constructor and Description |
|---|
TcpProtocol()
Creates and initializes a TcpProtocol instance.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
buildOptions(ConnectionsBuilder builder)
Overridden.
|
protected String |
getName()
Overridden.
|
protected void |
internalConnect()
Overridden.
|
protected void |
internalDisconnect()
Overridden.
|
protected void |
internalWritePacket(Packet packet)
Overridden.
|
protected boolean |
isValidOption(String name)
Validates if a protocol option is supported.
|
protected void |
loadOptions()
Overridden.
|
addListener, connect, disconnect, dispatch, dispose, doError, failed, getAppName, getBooleanOption, getBytesOption, getCaption, getHostName, getIntegerOption, getLevelOption, getRotateOption, getSizeOption, getStringOption, getTimespanOption, handleException, implConnect, implDisconnect, implDispatch, implWritePacket, initialize, internalDispatch, internalReconnect, internalWriteLogHeader, isAsynchronous, removeListener, reset, setAppName, setHostName, writePacketpublic TcpProtocol()
protected String getName()
protected boolean isValidOption(String name)
The following table lists all valid options, their default values and descriptions for the TCP protocol:
| Valid Options | Default Value | Description |
|---|---|---|
| host | "127.0.0.1" | Specifies the hostname where the Console is running |
| port | 4228 | Specifies the Console port |
| timeout | 30000 | Specifies the connect, receive and send timeout in milliseconds |
For further options which affect the behavior of this protocol, please have a look at the documentation of the Protocol.isValidOption method of the parent class. Example:
SiAuto.si.setConnections("tcp()");
SiAuto.si.setConnections("tcp(host=\\"localhost\\", port=4229)");
SiAuto.si.setConnections("tcp(timeout=2500)");
isValidOption in class Protocolname - The option name to validateprotected void buildOptions(ConnectionsBuilder builder)
buildOptions in class Protocolbuilder - The ConnectionsBuilder object to fill with the current options
of this protocolprotected void loadOptions()
This method loads all relevant options and ensures their correctness. See isValidOption for a list of options which are recognized by the TCP protocol
loadOptions in class Protocolprotected void internalConnect()
throws Exception
internalConnect in class ProtocolException - if creating or connecting the socket failedprotected void internalWritePacket(Packet packet) throws Exception
This method sends the supplied packet to the SmartInspect Console and waits for a valid response.
internalWritePacket in class Protocolpacket - The packet to writeException - If sending the packet to the Console failedprotected void internalDisconnect()
throws Exception
This method closes the underlying socket handle if previously created and disposes any supplemental objects.
internalDisconnect in class ProtocolException - If Closing the TCP socket failedCopyright © 2023. All rights reserved.