Class TCPTransportImpl
java.lang.Object
com.biglybt.core.networkmanager.impl.TransportImpl
com.biglybt.core.networkmanager.impl.tcp.TCPTransportImpl
- All Implemented Interfaces:
Transport
,TransportBase
Represents a peer TCP transport connection (eg. a network socket).
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.biglybt.core.networkmanager.Transport
Transport.ConnectListener
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) TCPConnectionManager.ConnectListener
(package private) boolean
(package private) String
(package private) final boolean
(package private) int
boolean
(package private) final boolean
(package private) boolean
(package private) static final LogIDs
(package private) AEProxyFactory.PluginProxy
private final ProtocolEndpointTCP
private byte[][]
private int
Fields inherited from interface com.biglybt.core.networkmanager.Transport
CR_BAD_PIECE_DATA, CR_DUPLICATE_PEER_ID, CR_INTERNAL_CONNECT_FAILED, CR_INVALID_INFO_HASH, CR_IP_BLOCKED, CR_NO_MEMORY, CR_NONE, CR_NOT_INTERESTED_UPLOAD_ONLY, CR_PEER_CHURN, CR_PORT_BLOCKED, CR_PROTOCOL_BLOCKED, CR_SELF_CONNECTION, CR_STOPPED_OR_REMOVED, CR_TIMEOUT, CR_TIMEOUT_ACTIVITY, CR_TIMEOUT_HANDSHAKE, CR_TIMEOUT_INTEREST, CR_TIMEOUT_REQUEST, CR_TOO_MANY_CONNECTIONS, CR_TOO_MANY_FILES, CR_UPLOAD_TO_UPLOAD, KEY_CLOSE_REASON, TRANSPORT_MODE_FAST, TRANSPORT_MODE_NORMAL, TRANSPORT_MODE_TURBO
-
Constructor Summary
ConstructorsConstructorDescriptionTCPTransportImpl
(ProtocolEndpointTCP endpoint, boolean use_crypto, boolean allow_fallback, byte[][] _shared_secrets) Constructor for disconnected (outbound) transport.TCPTransportImpl
(ProtocolEndpointTCP endpoint, TransportHelperFilter filter) Constructor for connected (inbound) transport. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
close
(TransportHelper helper, String reason) void
Close the transport connection.protected void
connectedOutbound
(ByteBuffer remaining_initial_data, Transport.ConnectListener listener) void
connectOutbound
(ByteBuffer initial_data, Transport.ConnectListener listener, int priority) Request the transport connection be established.Get a textual description for this transport.int
Get the socket channel used by the transport.Get the socket channel used by the transport.int
Get the transport's speed mode.protected void
handleCrypto
(InetSocketAddress address, SocketChannel channel, ByteBuffer initial_data, int priority, Transport.ConnectListener listener) boolean
isClosed()
boolean
boolean
isSOCKS()
boolean
isTCP()
(package private) void
setConnectResult
(boolean ok) private void
setTransportBuffersSize
(int size_in_bytes) void
setTransportMode
(int mode) Set the transport to the given speed mode.Methods inherited from class com.biglybt.core.networkmanager.impl.TransportImpl
bindConnection, connectedInbound, connectedOutbound, getEncryption, getFilter, getUserData, isEncrypted, isReadyForRead, isReadyForWrite, read, readFailed, readyForRead, readyForWrite, setAlreadyRead, setFilter, setReadyForRead, setTrace, setUserData, unbindConnection, write, writeFailed
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.biglybt.core.networkmanager.Transport
bindConnection, connectedInbound, getEncryption, getUserData, isEncrypted, read, setAlreadyRead, setReadyForRead, setTrace, setUserData, unbindConnection, write
Methods inherited from interface com.biglybt.core.networkmanager.TransportBase
isReadyForRead, isReadyForWrite
-
Field Details
-
LOGID
-
protocol_endpoint
-
connect_request_key
TCPConnectionManager.ConnectListener connect_request_key -
description
String description -
is_inbound_connection
final boolean is_inbound_connection -
transport_mode
private int transport_mode -
has_been_closed
public volatile boolean has_been_closed -
connect_with_crypto
boolean connect_with_crypto -
fallback_count
int fallback_count -
fallback_allowed
final boolean fallback_allowed -
is_socks
boolean is_socks -
plugin_proxy
-
-
Constructor Details
-
TCPTransportImpl
public TCPTransportImpl(ProtocolEndpointTCP endpoint, boolean use_crypto, boolean allow_fallback, byte[][] _shared_secrets) Constructor for disconnected (outbound) transport. -
TCPTransportImpl
Constructor for connected (inbound) transport.- Parameters:
channel
- connectionalready_read
- bytes from the channel
-
-
Method Details
-
isIncoming
public boolean isIncoming() -
getSocketChannel
Get the socket channel used by the transport.- Returns:
- the socket channel
-
getTransportEndpoint
Description copied from interface:Transport
Get the socket channel used by the transport.- Specified by:
getTransportEndpoint
in interfaceTransport
- Returns:
- the socket channel
-
getTransportStartpoint
- Specified by:
getTransportStartpoint
in interfaceTransport
- Overrides:
getTransportStartpoint
in classTransportImpl
-
getMssSize
public int getMssSize()- Specified by:
getMssSize
in interfaceTransport
-
isTCP
public boolean isTCP()- Specified by:
isTCP
in interfaceTransportBase
-
isSOCKS
public boolean isSOCKS()- Specified by:
isSOCKS
in interfaceTransport
- Overrides:
isSOCKS
in classTransportImpl
-
getPluginProxy
- Specified by:
getPluginProxy
in interfaceTransport
- Overrides:
getPluginProxy
in classTransportImpl
-
getProtocol
- Specified by:
getProtocol
in interfaceTransport
- Overrides:
getProtocol
in classTransportImpl
-
getDescription
Get a textual description for this transport.- Specified by:
getDescription
in interfaceTransportBase
- Returns:
- description
-
connectOutbound
public void connectOutbound(ByteBuffer initial_data, Transport.ConnectListener listener, int priority) Request the transport connection be established. NOTE: Will automatically connect via configured proxy if necessary.- Specified by:
connectOutbound
in interfaceTransport
- Parameters:
address
- remote peer address to connect tolistener
- establishment failure/success listener
-
handleCrypto
protected void handleCrypto(InetSocketAddress address, SocketChannel channel, ByteBuffer initial_data, int priority, Transport.ConnectListener listener) -
setTransportBuffersSize
private void setTransportBuffersSize(int size_in_bytes) -
setTransportMode
public void setTransportMode(int mode) Set the transport to the given speed mode.- Specified by:
setTransportMode
in interfaceTransport
- Parameters:
mode
- to change to
-
connectedOutbound
protected void connectedOutbound(ByteBuffer remaining_initial_data, Transport.ConnectListener listener) -
getTransportMode
public int getTransportMode()Get the transport's speed mode.- Specified by:
getTransportMode
in interfaceTransport
- Returns:
- current mode
-
close
-
setConnectResult
void setConnectResult(boolean ok) -
close
Close the transport connection. -
isClosed
public boolean isClosed()
-