public interface TcpConnection
Modifier and Type | Interface and Description |
---|---|
static interface |
TcpConnection.Listener
The interface represents a listener for the TCP connection events
|
Modifier and Type | Field and Description |
---|---|
static TcpConnection.Listener |
NULL_LISTENER
This field represents a dummy implementation of the
TcpConnection.Listener interface. |
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the connection.
|
long |
getOutQueueBytes()
Returns the number of bytes in the out queue to be send.
|
boolean |
isClosed()
Returns true if the connection is closed, false otherwise.
|
boolean |
isSenderStillInactive()
Returns true if no data is sent and it remains inactive, false otherwise.
|
void |
send(ByteBuffer byteBuffer)
Sends the given
ByteBuffer through the connection. |
void |
setListener(TcpConnection.Listener listener)
Sets the listener to listen for events.
|
void |
setReceiverSpinningTimeout(long timeout,
TimeUnit timeUnit)
Sets the receiving data spinning timeout.
|
void |
setReceiverThreadName(String name)
Sets the name for the receiver thread if the connection use
ConnectionMode.DEDICATED_THREADS mode. |
void |
setReceiverTimeout(long timeout,
TimeUnit timeUnit)
Sets the timeout for the receiving data.
|
void |
setSenderSpinningTimeout(long timeout,
TimeUnit timeUnit)
Sets the sending data spinning timeout.
|
void |
setSenderTimeout(long timeout,
TimeUnit timeUnit)
Sets the timeout for the sending data.
|
void |
setSendQueueMaxSize(int size)
Sets the maximum size for the send queue.
|
void |
startReceiver()
Starts the receiving data.
|
void |
startSender()
Starts the sending data.
|
static final TcpConnection.Listener NULL_LISTENER
TcpConnection.Listener
interface.void startSender()
void startReceiver() throws IOException
IOException
- if an I/O error occurs.void send(ByteBuffer byteBuffer)
ByteBuffer
through the connection.byteBuffer
- the buffer to be sent.void setListener(TcpConnection.Listener listener)
listener
- the listener to be set.void close()
boolean isClosed()
boolean isSenderStillInactive()
long getOutQueueBytes()
void setSenderTimeout(long timeout, TimeUnit timeUnit)
timeout
- the timeout value, in case it is 0, the timeout will never elapse.timeUnit
- the time unit for the timeout value.void setReceiverTimeout(long timeout, TimeUnit timeUnit)
timeout
- the timeout value, in case it is 0, the timeout will never elapse.timeUnit
- the time unit for the timeout value.void setSenderSpinningTimeout(long timeout, TimeUnit timeUnit)
timeout
- the timeout value.timeUnit
- the time unit for the timeout value.void setReceiverSpinningTimeout(long timeout, TimeUnit timeUnit)
timeout
- the timeout value.timeUnit
- the time unit for the timeout value.void setSendQueueMaxSize(int size)
If the max size of the sending queue is reached the send(ByteBuffer)
method call
will throw an exception
size
- the maximum size for the send queue.void setReceiverThreadName(String name)
ConnectionMode.DEDICATED_THREADS
mode.name
- the name of the receiver thread.Copyright © 2005–2024 Onix Solutions. All rights reserved.