Class TransportImpl
java.lang.Object
com.biglybt.core.networkmanager.impl.TransportImpl
- All Implemented Interfaces:
Transport
,TransportBase
- Direct Known Subclasses:
TCPTransportImpl
,UDPTransport
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.biglybt.core.networkmanager.Transport
Transport.ConnectListener
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate ByteBuffer
private TransportHelperFilter
private boolean
private boolean
private long
private Throwable
private EventWaiter
private static final TransportStats
private boolean
private Throwable
private EventWaiter
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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
bindConnection
(NetworkConnection connection) void
Indicate that inbound connection is completevoid
getEncryption
(boolean verbose) Return a textual description of the encryption for this transportgetUserData
(Object key) boolean
long
isReadyForRead
(EventWaiter waiter) Is the transport ready to read, i.e.boolean
isReadyForWrite
(EventWaiter waiter) Is the transport ready to write, i.e.boolean
isSOCKS()
long
read
(ByteBuffer[] buffers, int array_offset, int length) Read data from the transport into the given buffers.protected void
readFailed
(Throwable msg) protected boolean
readyForRead
(boolean ready) protected boolean
readyForWrite
(boolean ready) private void
private void
private void
void
setAlreadyRead
(ByteBuffer bytes_already_read) Inject the given already-read data back into the read stream.void
setFilter
(TransportHelperFilter _filter) void
fake a wakeup so that a read cycle is attemptedvoid
setTrace
(boolean on) void
setUserData
(Object key, Object value) void
unbindConnection
(NetworkConnection connection) long
write
(ByteBuffer[] buffers, int array_offset, int length) Write data to the transport from the given buffers.protected void
writeFailed
(Throwable msg) 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
close, connectOutbound, getMssSize, getTransportEndpoint, getTransportMode, isClosed, setTransportMode
Methods inherited from interface com.biglybt.core.networkmanager.TransportBase
getDescription, isTCP
-
Field Details
-
filter
-
stats
-
data_already_read
-
read_waiter
-
write_waiter
-
is_ready_for_write
private volatile boolean is_ready_for_write -
is_ready_for_read
private volatile boolean is_ready_for_read -
write_select_failure
-
read_select_failure
-
last_ready_for_read
private long last_ready_for_read -
trace
private boolean trace
-
-
Constructor Details
-
TransportImpl
protected TransportImpl()
-
-
Method Details
-
getTransportStartpoint
- Specified by:
getTransportStartpoint
in interfaceTransport
-
setFilter
-
getFilter
-
setAlreadyRead
Description copied from interface:Transport
Inject the given already-read data back into the read stream.- Specified by:
setAlreadyRead
in interfaceTransport
- Parameters:
bytes_already_read
- data
-
getEncryption
Description copied from interface:Transport
Return a textual description of the encryption for this transport- Specified by:
getEncryption
in interfaceTransport
- Returns:
-
getProtocol
- Specified by:
getProtocol
in interfaceTransport
-
isEncrypted
public boolean isEncrypted()- Specified by:
isEncrypted
in interfaceTransport
-
isSOCKS
public boolean isSOCKS() -
getPluginProxy
- Specified by:
getPluginProxy
in interfaceTransport
-
isReadyForWrite
Is the transport ready to write, i.e. will a write request result in >0 bytes written.- Specified by:
isReadyForWrite
in interfaceTransportBase
- Returns:
- true if the transport is write ready, false if not yet ready
-
readyForWrite
protected boolean readyForWrite(boolean ready) -
writeFailed
-
isReadyForRead
Is the transport ready to read, i.e. will a read request result in >0 bytes read.- Specified by:
isReadyForRead
in interfaceTransportBase
- Returns:
- 0 if the transport is read ready, millis since last ready or -1 if never ready
-
readyForRead
protected boolean readyForRead(boolean ready) -
setReadyForRead
public void setReadyForRead()Description copied from interface:Transport
fake a wakeup so that a read cycle is attempted- Specified by:
setReadyForRead
in interfaceTransport
-
readFailed
-
write
Write data to the transport from the given buffers. NOTE: Works like GatheringByteChannel.- Specified by:
write
in interfaceTransport
- Parameters:
buffers
- from which bytes are to be retrievedarray_offset
- offset within the buffer array of the first buffer from which bytes are to be retrievedlength
- maximum number of buffers to be accessed- Returns:
- number of bytes written
- Throws:
IOException
- on write error
-
read
Read data from the transport into the given buffers. NOTE: Works like ScatteringByteChannel.- Specified by:
read
in interfaceTransport
- Parameters:
buffers
- into which bytes are to be placedarray_offset
- offset within the buffer array of the first buffer into which bytes are to be placedlength
- maximum number of buffers to be accessed- Returns:
- number of bytes read
- Throws:
IOException
- on read error
-
requestWriteSelect
private void requestWriteSelect() -
requestReadSelect
private void requestReadSelect() -
connectedInbound
public void connectedInbound()Description copied from interface:Transport
Indicate that inbound connection is complete- Specified by:
connectedInbound
in interfaceTransport
-
connectedOutbound
public void connectedOutbound() -
bindConnection
- Specified by:
bindConnection
in interfaceTransport
-
unbindConnection
- Specified by:
unbindConnection
in interfaceTransport
-
getUserData
- Specified by:
getUserData
in interfaceTransport
-
setUserData
- Specified by:
setUserData
in interfaceTransport
-
registerSelectHandling
private void registerSelectHandling() -
setTrace
public void setTrace(boolean on)
-