Class TCPTransportImpl
- java.lang.Object
-
- com.biglybt.core.networkmanager.impl.TransportImpl
-
- com.biglybt.core.networkmanager.impl.tcp.TCPTransportImpl
-
- All Implemented Interfaces:
Transport
,TransportBase
public class TCPTransportImpl extends TransportImpl implements Transport
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
Fields Modifier and Type Field Description (package private) TCPConnectionManager.ConnectListener
connect_request_key
(package private) boolean
connect_with_crypto
(package private) java.lang.String
description
(package private) boolean
fallback_allowed
(package private) int
fallback_count
boolean
has_been_closed
(package private) boolean
is_inbound_connection
(package private) boolean
is_socks
(package private) static LogIDs
LOGID
(package private) AEProxyFactory.PluginProxy
plugin_proxy
private ProtocolEndpointTCP
protocol_endpoint
private byte[][]
shared_secrets
private int
transport_mode
-
Fields inherited from interface com.biglybt.core.networkmanager.Transport
TRANSPORT_MODE_FAST, TRANSPORT_MODE_NORMAL, TRANSPORT_MODE_TURBO
-
-
Constructor Summary
Constructors Constructor Description TCPTransportImpl(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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
close(TransportHelper helper, java.lang.String reason)
void
close(java.lang.String reason)
Close the transport connection.protected void
connectedOutbound(java.nio.ByteBuffer remaining_initial_data, Transport.ConnectListener listener)
void
connectOutbound(java.nio.ByteBuffer initial_data, Transport.ConnectListener listener, int priority)
Request the transport connection be established.java.lang.String
getDescription()
Get a textual description for this transport.int
getMssSize()
java.lang.String
getProtocol()
java.nio.channels.SocketChannel
getSocketChannel()
Get the socket channel used by the transport.TransportEndpointTCP
getTransportEndpoint()
Get the socket channel used by the transport.int
getTransportMode()
Get the transport's speed mode.TransportStartpoint
getTransportStartpoint()
protected void
handleCrypto(java.net.InetSocketAddress address, java.nio.channels.SocketChannel channel, java.nio.ByteBuffer initial_data, int priority, Transport.ConnectListener listener)
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 Detail
-
LOGID
static final LogIDs LOGID
-
protocol_endpoint
private final ProtocolEndpointTCP protocol_endpoint
-
connect_request_key
TCPConnectionManager.ConnectListener connect_request_key
-
description
java.lang.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
-
shared_secrets
private byte[][] shared_secrets
-
fallback_count
int fallback_count
-
fallback_allowed
final boolean fallback_allowed
-
is_socks
boolean is_socks
-
plugin_proxy
volatile AEProxyFactory.PluginProxy plugin_proxy
-
-
Constructor Detail
-
TCPTransportImpl
public TCPTransportImpl(ProtocolEndpointTCP endpoint, boolean use_crypto, boolean allow_fallback, byte[][] _shared_secrets)
Constructor for disconnected (outbound) transport.
-
TCPTransportImpl
public TCPTransportImpl(ProtocolEndpointTCP endpoint, TransportHelperFilter filter)
Constructor for connected (inbound) transport.- Parameters:
channel
- connectionalready_read
- bytes from the channel
-
-
Method Detail
-
getSocketChannel
public java.nio.channels.SocketChannel getSocketChannel()
Get the socket channel used by the transport.- Returns:
- the socket channel
-
getTransportEndpoint
public TransportEndpointTCP getTransportEndpoint()
Description copied from interface:Transport
Get the socket channel used by the transport.- Specified by:
getTransportEndpoint
in interfaceTransport
- Returns:
- the socket channel
-
getTransportStartpoint
public TransportStartpoint 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
-
getProtocol
public java.lang.String getProtocol()
- Specified by:
getProtocol
in interfaceTransport
- Overrides:
getProtocol
in classTransportImpl
-
getDescription
public java.lang.String getDescription()
Get a textual description for this transport.- Specified by:
getDescription
in interfaceTransportBase
- Returns:
- description
-
connectOutbound
public void connectOutbound(java.nio.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(java.net.InetSocketAddress address, java.nio.channels.SocketChannel channel, java.nio.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(java.nio.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
protected void close(TransportHelper helper, java.lang.String reason)
-
setConnectResult
void setConnectResult(boolean ok)
-
-