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 Transport
Transport.ConnectListener -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate ByteBufferprivate TransportHelperFilterprivate booleanprivate booleanprivate longprivate Throwableprivate EventWaiterprivate static final TransportStatsprivate booleanprivate Throwableprivate EventWaiterFields inherited from interface 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_MEGA_TURBO, TRANSPORT_MODE_NORMAL, TRANSPORT_MODE_TURBO -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidbindConnection(NetworkConnection connection) voidIndicate that inbound connection is completevoidgetEncryption(boolean verbose) Return a textual description of the encryption for this transportgetUserData(Object key) booleanlongisReadyForRead(EventWaiter waiter) Is the transport ready to read, i.e.booleanisReadyForWrite(EventWaiter waiter) Is the transport ready to write, i.e.booleanisSOCKS()longread(ByteBuffer[] buffers, int array_offset, int length) Read data from the transport into the given buffers.protected voidreadFailed(Throwable msg) protected booleanreadyForRead(boolean ready) protected booleanreadyForWrite(boolean ready) private voidprivate voidprivate voidvoidsetAlreadyRead(ByteBuffer bytes_already_read) Inject the given already-read data back into the read stream.voidsetFilter(TransportHelperFilter _filter) voidfake a wakeup so that a read cycle is attemptedvoidsetTrace(boolean on) voidsetUserData(Object key, Object value) voidunbindConnection(NetworkConnection connection) longwrite(ByteBuffer[] buffers, int array_offset, int length) Write data to the transport from the given buffers.protected voidwriteFailed(Throwable msg) Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Transport
close, connectOutbound, getMssSize, getTransportEndpoint, getTransportMode, isClosed, setTransportMode, setTransportModesMethods inherited from interface 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:
getTransportStartpointin interfaceTransport
-
setFilter
-
getFilter
-
setAlreadyRead
Description copied from interface:TransportInject the given already-read data back into the read stream.- Specified by:
setAlreadyReadin interfaceTransport- Parameters:
bytes_already_read- data
-
getEncryption
Description copied from interface:TransportReturn a textual description of the encryption for this transport- Specified by:
getEncryptionin interfaceTransport- Returns:
-
getProtocol
- Specified by:
getProtocolin interfaceTransport
-
isEncrypted
public boolean isEncrypted()- Specified by:
isEncryptedin interfaceTransport
-
isSOCKS
-
getPluginProxy
- Specified by:
getPluginProxyin interfaceTransport
-
isReadyForWrite
Is the transport ready to write, i.e. will a write request result in >0 bytes written.- Specified by:
isReadyForWritein 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:
isReadyForReadin 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:Transportfake a wakeup so that a read cycle is attempted- Specified by:
setReadyForReadin interfaceTransport
-
readFailed
-
write
Write data to the transport from the given buffers. NOTE: Works like GatheringByteChannel.- Specified by:
writein 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:
readin 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:TransportIndicate that inbound connection is complete- Specified by:
connectedInboundin interfaceTransport
-
connectedOutbound
public void connectedOutbound() -
bindConnection
- Specified by:
bindConnectionin interfaceTransport
-
unbindConnection
- Specified by:
unbindConnectionin interfaceTransport
-
getUserData
- Specified by:
getUserDatain interfaceTransport
-
setUserData
- Specified by:
setUserDatain interfaceTransport
-
registerSelectHandling
private void registerSelectHandling() -
setTrace
-