public class SctpMultiSession extends AbstractSession implements ISctpMultiSession
It uses the message-oriented connected SCTP socket as described in the IETF RFC 4960 "Stream Control Transmission Protocol".
| Modifier and Type | Method and Description |
|---|---|
ByteBuffer |
allocate(int capacity)
Allocates a byte buffer by using the allocator associated with this session.
|
IFuture<Void> |
bindAddress(InetAddress address)
Adds the given address to the bound addresses for the SCTP channel's socket
associated with this session
|
void |
close()
Gently closes this session after all pending data waiting for writing are fully flushed.
|
void |
dirtyClose()
Quickly closes this session without flushing any pending data and without following
close procedure of an application layer (e.g.
|
IFuture<Void> |
execute(Runnable task)
Executes a task in the selector-loop's thread this session is registered
with.
|
void |
executenf(Runnable task)
Executes a task in the selector-loop's thread this session is registered
with.
|
com.sun.nio.sctp.Association |
getAssociation()
Returns the association on the SCTP channel's socket associated with this
session
|
Set<com.sun.nio.sctp.Association> |
getAssociations()
Returns the open associations on the SCTP multi-channel's socket associated
with this session.
|
IFuture<Void> |
getCloseFuture()
Gets the future that can be use to wait for the completion of the closing
phase.
|
ICodecPipeline |
getCodecPipeline()
Gets the codec pipeline that is associated with this session.
|
ICodecPipeline |
getCodecPipeline(Object identifier)
Gets the codec pipeline that is associated with this session and is
identified by the given identifier.
|
ISessionConfig |
getConfig()
Gets the configuration of this session.
|
IFuture<Void> |
getCreateFuture()
Gets the future that can be use to wait for the completion of the
creation phase.
|
long |
getCreationTime()
Gets the session's creation time in milliseconds.
|
IFuture<Void> |
getEndFuture()
Gets the future that can be use to wait for the completion of the ending
phase.
|
ISctpHandler |
getHandler()
Gets the SCTP handler associated with this session
|
long |
getLastIoTime()
Gets the time in milliseconds when I/O operation occurred lastly.
|
long |
getLastReadTime()
Gets the time in milliseconds when read operation occurred lastly.
|
long |
getLastWriteTime()
Gets the time in milliseconds when write operation occurred lastly.
|
SocketAddress |
getLocalAddress()
Returns one of the local addresses this session is bound to.
|
Set<SocketAddress> |
getLocalAddresses()
Returns all of the socket addresses to which the SCTP channel associated with
this session is bound.
|
IFuture<Void> |
getOpenFuture()
Gets the future that can be use to wait for the completion of the opening
phase.
|
ISctpMultiSession |
getParent()
Gets the parent session.
|
long |
getReadBytes()
Gets the total number of bytes which were read from this session.
|
double |
getReadBytesThroughput()
Gets the number of read bytes per second.
|
IFuture<Void> |
getReadyFuture()
Gets the future that can be use to wait for the completion of the ready
phase.
|
SocketAddress |
getRemoteAddress()
Returns one of the remote addresses to which this session is connected.
|
Set<SocketAddress> |
getRemoteAddresses()
Returns all of the remote addresses to which the SCTP channel associated with
this session is connected.
|
Set<SocketAddress> |
getRemoteAddresses(com.sun.nio.sctp.Association association)
Returns all of the remote addresses to which the given association on the
SCTP multi-channel's socket associated with this session.
|
SessionState |
getState()
Gets the current state of this session.
|
ISessionTimer |
getTimer()
Gets the session timer associated with this session.
|
long |
getWrittenBytes()
Gets the total number of bytes which were written to this session.
|
double |
getWrittenBytesThroughput()
Gets the number of written bytes per second.
|
boolean |
isDataCopyingOptimized()
Tells if the processing of data is optimized to reduce data copying between
byte buffers.
|
boolean |
isOpen()
Tells if this session is open.
|
boolean |
isReadSuspended()
Tells if read operations are suspended for this session.
|
boolean |
isWriteSuspended()
Tells if write operations are suspended for this session.
|
void |
quickClose()
Quickly closes this session without flushing any pending data.
|
void |
release(ByteBuffer buffer)
Release given byte buffer by the allocator associated with this session.
|
void |
resumeRead()
Resumes read operations for this session.
|
void |
resumeWrite()
Resumes write operations for this session.
|
IFuture<Void> |
shutdown(com.sun.nio.sctp.Association association)
Shutdown an association without closing this session.
|
void |
suspendRead()
Suspends read operations for this session.
|
void |
suspendWrite()
Suspends write operations for this session.
|
IFuture<Void> |
unbindAddress(InetAddress address)
Removes the given address from the bound addresses for the SCTP channel's
socket associated with this session
|
IFuture<Void> |
write(byte[] msg)
Writes a message from the specified byte array to the SCTP channel that is
associated with this session.
|
IFuture<Void> |
write(byte[] msg,
ImmutableSctpMessageInfo msgInfo)
Writes a message from the specified byte array to the SCTP channel that is
associated with this session.
|
IFuture<Void> |
write(byte[] msg,
int offset,
int length)
Writes a message of given length from the specified byte array to the SCTP
channel that is associated with this session.
|
IFuture<Void> |
write(byte[] msg,
int offset,
int length,
ImmutableSctpMessageInfo msgInfo)
Writes a message of given length from the specified byte array to the SCTP
channel that is associated with this session.
|
IFuture<Void> |
write(ByteBuffer msg)
Writes a message from the specified byte buffer to the SCTP channel that is
associated with this session.
|
IFuture<Void> |
write(ByteBuffer msg,
ImmutableSctpMessageInfo msgInfo)
Writes a message from the specified byte buffer to the SCTP channel that is
associated with this session.
|
IFuture<Void> |
write(ByteBuffer msg,
int length)
Writes a message of given length from the specified byte buffer to the SCTP
channel that is associated with this session.
|
IFuture<Void> |
write(ByteBuffer msg,
int length,
ImmutableSctpMessageInfo msgInfo)
Writes a message of given length from the specified byte buffer to the SCTP
channel that is associated with this session.
|
IFuture<Void> |
write(Object msg)
Writes a message to the SCTP channel that is associated with this session.
|
IFuture<Void> |
write(Object msg,
ImmutableSctpMessageInfo msgInfo)
Writes a message to the SCTP channel that is associated with this session.
|
void |
writenf(byte[] msg)
Writes a message from the specified byte array to the SCTP channel that is
associated with this session.
|
void |
writenf(byte[] msg,
ImmutableSctpMessageInfo msgInfo)
Writes a message from the specified byte array to the SCTP channel that is
associated with this session.
|
void |
writenf(byte[] msg,
int offset,
int length)
Writes a message of given length from the specified byte array to the SCTP
channel that is associated with this session.
|
void |
writenf(byte[] msg,
int offset,
int length,
ImmutableSctpMessageInfo msgInfo)
Writes a message of given length from the specified byte array to the SCTP
channel that is associated with this session.
|
void |
writenf(ByteBuffer msg)
Writes a message from the specified byte buffer to the SCTP channel that is
associated with this session.
|
void |
writenf(ByteBuffer msg,
ImmutableSctpMessageInfo msgInfo)
Writes a message from the specified byte buffer to the SCTP channel that is
associated with this session.
|
void |
writenf(ByteBuffer msg,
int length)
Writes a message of given length from the specified byte buffer to the SCTP
channel that is associated with this session.
|
void |
writenf(ByteBuffer msg,
int length,
ImmutableSctpMessageInfo msgInfo)
Writes a message of given length from the specified byte buffer to the SCTP
channel that is associated with this session.
|
void |
writenf(Object msg)
Writes a message to the SCTP channel that is associated with this session.
|
void |
writenf(Object msg,
ImmutableSctpMessageInfo msgInfo)
Writes a message to the SCTP channel that is associated with this session.
|
getAttributesgetId, getName, toStringclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitbindAddress, getCodecPipeline, getHandler, getLocalAddress, getLocalAddresses, unbindAddress, write, write, write, write, write, writenf, writenf, writenf, writenf, writenfallocate, close, dirtyClose, execute, executenf, getAttributes, getCloseFuture, getCodecPipeline, getConfig, getCreateFuture, getCreationTime, getEndFuture, getId, getLastIoTime, getLastReadTime, getLastWriteTime, getName, getOpenFuture, getReadBytes, getReadBytesThroughput, getReadyFuture, getState, getTimer, getWrittenBytes, getWrittenBytesThroughput, isDataCopyingOptimized, isOpen, isReadSuspended, isWriteSuspended, quickClose, release, resumeRead, resumeWrite, suspendRead, suspendWritepublic ISctpMultiSession getParent()
ISessionSome sessions may not implement its own I/O functionalities and use their parent's ones instead.
getParent in interface ISctpMultiSessiongetParent in interface ISctpSessiongetParent in interface ISessionnull if it does not exist.public IFuture<Void> shutdown(com.sun.nio.sctp.Association association)
ISctpMultiSessionshutdown in interface ISctpMultiSessionassociation - the association to shutdownpublic com.sun.nio.sctp.Association getAssociation()
ISctpSessiongetAssociation in interface ISctpSessionnull if the SCTP channel's socket is not
connectedpublic Set<com.sun.nio.sctp.Association> getAssociations()
ISctpMultiSessiongetAssociations in interface ISctpMultiSessionSet if there are nonepublic SocketAddress getRemoteAddress()
ISctpSessionNOTE: The return address cannot be treated as the peer's primary address. It is the application's responsibility to keep track of it's peer's primary address.
getRemoteAddress in interface ISctpSessiongetRemoteAddress in interface ISessionnull if this session is not
connected yetSocketpublic Set<SocketAddress> getRemoteAddresses()
ISctpSessiongetRemoteAddresses in interface ISctpMultiSessiongetRemoteAddresses in interface ISctpSessionpublic Set<SocketAddress> getRemoteAddresses(com.sun.nio.sctp.Association association)
ISctpMultiSessiongetRemoteAddresses in interface ISctpMultiSessionassociation - the given associationSet if the association has been shutdownpublic IFuture<Void> write(byte[] msg)
ISctpSessioncom.sun.nio.sctp.MessageInfo created based on the default values for
address, streamNumber, payloadProtocolID and
unordered that were read from the session's configuration during
creation of this session.
The operation is asynchronous.
write in interface ISctpMultiSessionwrite in interface ISctpSessionmsg - the byte array containing the message to be writtenpublic IFuture<Void> write(byte[] msg, int offset, int length)
ISctpSessioncom.sun.nio.sctp.MessageInfo created based on the default
values for address, streamNumber, payloadProtocolID
and unordered that were read from the session's configuration during
creation of this session.
The operation is asynchronous.
write in interface ISctpMultiSessionwrite in interface ISctpSessionmsg - the byte array containing the message to be writtenoffset - offset within the array of the first byte to be writtenlength - number of bytes to be writtenpublic void writenf(byte[] msg)
ISctpSessioncom.sun.nio.sctp.MessageInfo created based on the default values for
address, streamNumber, payloadProtocolID and
unordered that were read from the session's configuration during
creation of this session.
The operation is asynchronous.
This method should be used whenever there will be no need to synchronize on a future object. This will save some resources and may improve performance.
writenf in interface ISctpMultiSessionwritenf in interface ISctpSessionmsg - the byte array containing the message to be writtenpublic void writenf(byte[] msg,
int offset,
int length)
ISctpSessioncom.sun.nio.sctp.MessageInfo created based on the default
values for address, streamNumber, payloadProtocolID
and unordered that were read from the session's configuration during
creation of this session.
The operation is asynchronous.
This method should be used whenever there will be no need to synchronize on a future object. This will save some resources and may improve performance.
writenf in interface ISctpMultiSessionwritenf in interface ISctpSessionmsg - the byte array containing the message to be writtenoffset - offset within the array of the first byte to be writtenlength - number of bytes to be writtenpublic IFuture<Void> write(ByteBuffer msg)
ISctpSessioncom.sun.nio.sctp.MessageInfo created based on the default values for
address, streamNumber, payloadProtocolID and
unordered that were read from the session's configuration during
creation of this session.
The operation is asynchronous.
write in interface ISctpMultiSessionwrite in interface ISctpSessionmsg - the byte array containing the message to be writtenpublic IFuture<Void> write(ByteBuffer msg, int length)
ISctpSessioncom.sun.nio.sctp.MessageInfo created based on the default
values for address, streamNumber, payloadProtocolID
and unordered that were read from the session's configuration during
creation of this session.
The operation is asynchronous.
write in interface ISctpMultiSessionwrite in interface ISctpSessionmsg - the byte array containing the message to be writtenlength - number of bytes to be writtenpublic void writenf(ByteBuffer msg)
ISctpSessioncom.sun.nio.sctp.MessageInfo created based on the default values for
address, streamNumber, payloadProtocolID and
unordered that were read from the session's configuration during
creation of this session.
The operation is asynchronous.
This method should be used whenever there will be no need to synchronize on a future object. This will save some resources and may improve performance.
writenf in interface ISctpMultiSessionwritenf in interface ISctpSessionmsg - the byte array containing the message to be writtenpublic void writenf(ByteBuffer msg, int length)
ISctpSessioncom.sun.nio.sctp.MessageInfo created based on the default
values for address, streamNumber, payloadProtocolID
and unordered that were read from the session's configuration during
creation of this session.
The operation is asynchronous.
This method should be used whenever there will be no need to synchronize on a future object. This will save some resources and may improve performance.
writenf in interface ISctpMultiSessionwritenf in interface ISctpSessionmsg - the byte array containing the message to be writtenlength - number of bytes to be writtenpublic IFuture<Void> write(Object msg)
ISctpSessioncom.sun.nio.sctp.MessageInfo
created based on the default values for address,
streamNumber, payloadProtocolID and unordered that
were read from the session's configuration during creation of this session.
The operation is asynchronous.
This method usually requires that the session has configured a codec pipeline
with at least one encoder that accepts the msg as the inbound data. If a
codec pipeline is not configured or no encoder accept the msg object it still
accepts messages that are of the byte[] or ByteBuffer
type.
write in interface ISctpMultiSessionwrite in interface ISctpSessionmsg - the byte array containing the message to be writtenpublic void writenf(Object msg)
ISctpSessioncom.sun.nio.sctp.MessageInfo
created based on the default values for address,
streamNumber, payloadProtocolID and unordered that
were read from the session's configuration during creation of this session.
The operation is asynchronous.
This method usually requires that the session has configured a codec pipeline
with at least one encoder that accepts the msg as the inbound data. If a
codec pipeline is not configured or no encoder accept the msg object it still
accepts messages that are of the byte[] or ByteBuffer
type.
This method should be used whenever there will be no need to synchronize on a future object. This will save some resources and may improve performance.
writenf in interface ISctpMultiSessionwritenf in interface ISctpSessionmsg - the byte array containing the message to be writtenpublic ISctpHandler getHandler()
ISctpSessiongetHandler in interface ISctpSessiongetHandler in interface ISessionpublic void close()
ISessionAfter returning from this method any consecutive writes will be simply discarded.
public void quickClose()
ISessionAfter returning from this method any consecutive writes will be simply discarded.
quickClose in interface ISessionpublic ICodecPipeline getCodecPipeline(Object identifier)
ISctpSessiongetCodecPipeline in interface ISctpSessionidentifier - the identifier of the codec pipelinenull if the session does not support it
or it has not been created yetpublic SocketAddress getLocalAddress()
ISctpSessionNOTE: The return address cannot be treated as the local primary address. It is the application's responsibility to keep track of it's local primary address.
getLocalAddress in interface ISctpSessiongetLocalAddress in interface ISessionnull if this session is not
bound yetSocketpublic Set<SocketAddress> getLocalAddresses()
ISctpSessiongetLocalAddresses in interface ISctpSessionpublic IFuture<Void> bindAddress(InetAddress address)
ISctpSessionbindAddress in interface ISctpSessionaddress - the address to add to the bound addressespublic IFuture<Void> unbindAddress(InetAddress address)
ISctpSessionunbindAddress in interface ISctpSessionaddress - the address to remove from the bound addressespublic IFuture<Void> write(byte[] msg, ImmutableSctpMessageInfo msgInfo)
ISctpSessioncom.sun.nio.sctp.MessageInfo created based on the specified immutable
ancillary data.
The operation is asynchronous.
write in interface ISctpSessionmsg - the byte array containing the message to be writtenmsgInfo - immutable ancillary data about the message to be writtenpublic IFuture<Void> write(byte[] msg, int offset, int length, ImmutableSctpMessageInfo msgInfo)
ISctpSessioncom.sun.nio.sctp.MessageInfo created based on the specified immutable
ancillary data.
The operation is asynchronous.
write in interface ISctpSessionmsg - the byte array containing the message to be writtenoffset - offset within the array of the first byte to be writtenlength - number of bytes to be writtenmsgInfo - immutable ancillary data about the message to be writtenpublic void writenf(byte[] msg,
ImmutableSctpMessageInfo msgInfo)
ISctpSessioncom.sun.nio.sctp.MessageInfo created based on the specified immutable
ancillary data.
The operation is asynchronous.
This method should be used whenever there will be no need to synchronize on a future object. This will save some resources and may improve performance.
writenf in interface ISctpSessionmsg - the byte array containing the message to be writtenmsgInfo - immutable ancillary data about the message to be writtenpublic void writenf(byte[] msg,
int offset,
int length,
ImmutableSctpMessageInfo msgInfo)
ISctpSessioncom.sun.nio.sctp.MessageInfo created based on the specified immutable
ancillary data.
The operation is asynchronous.
This method should be used whenever there will be no need to synchronize on a future object. This will save some resources and may improve performance.
writenf in interface ISctpSessionmsg - the byte array containing the message to be writtenoffset - offset within the array of the first byte to be writtenlength - number of bytes to be writtenmsgInfo - immutable ancillary data about the message to be writtenpublic IFuture<Void> write(ByteBuffer msg, int length, ImmutableSctpMessageInfo msgInfo)
ISctpSessioncom.sun.nio.sctp.MessageInfo created based on the specified immutable
ancillary data.
The operation is asynchronous.
write in interface ISctpSessionmsg - the byte array containing the message to be writtenlength - number of bytes to be writtenmsgInfo - immutable ancillary data about the message to be writtenpublic void writenf(ByteBuffer msg, ImmutableSctpMessageInfo msgInfo)
ISctpSessioncom.sun.nio.sctp.MessageInfo created based on the specified immutable
ancillary data.
The operation is asynchronous.
This method should be used whenever there will be no need to synchronize on a future object. This will save some resources and may improve performance.
writenf in interface ISctpSessionmsg - the byte array containing the message to be writtenmsgInfo - immutable ancillary data about the message to be writtenpublic void writenf(ByteBuffer msg, int length, ImmutableSctpMessageInfo msgInfo)
ISctpSessioncom.sun.nio.sctp.MessageInfo created based on the specified immutable
ancillary data.
The operation is asynchronous.
This method should be used whenever there will be no need to synchronize on a future object. This will save some resources and may improve performance.
writenf in interface ISctpSessionmsg - the byte array containing the message to be writtenlength - number of bytes to be writtenmsgInfo - immutable ancillary data about the message to be writtenpublic IFuture<Void> write(Object msg, ImmutableSctpMessageInfo msgInfo)
ISctpSessioncom.sun.nio.sctp.MessageInfo
created based on the specified immutable ancillary data.
The operation is asynchronous.
This method usually requires that the session has configured a codec pipeline
with at least one encoder that accepts the msg as the inbound data. If a
codec pipeline is not configured or no encoder accept the msg object it still
accepts messages that are of the byte[] or ByteBuffer
type.
write in interface ISctpSessionmsg - the byte array containing the message to be writtenmsgInfo - immutable ancillary data about the message to be writtenpublic IFuture<Void> write(ByteBuffer msg, ImmutableSctpMessageInfo msgInfo)
ISctpSessioncom.sun.nio.sctp.MessageInfo created based on the specified immutable
ancillary data.
The operation is asynchronous.
write in interface ISctpSessionmsg - the byte array containing the message to be writtenmsgInfo - immutable ancillary data about the message to be writtenpublic void writenf(Object msg, ImmutableSctpMessageInfo msgInfo)
ISctpSessioncom.sun.nio.sctp.MessageInfo
created based on the specified immutable ancillary data.
The operation is asynchronous.
This method usually requires that the session has configured a codec pipeline
with at least one encoder that accepts the msg as the inbound data. If a
codec pipeline is not configured or no encoder accept the msg object it still
accepts messages that are of the byte[] or ByteBuffer
type.
This method should be used whenever there will be no need to synchronize on a future object. This will save some resources and may improve performance.
writenf in interface ISctpSessionmsg - the byte array containing the message to be writtenmsgInfo - immutable ancillary data about the message to be writtenpublic IFuture<Void> getCreateFuture()
ISessiongetCreateFuture in interface ISessionpublic IFuture<Void> getOpenFuture()
ISessiongetOpenFuture in interface ISessionpublic IFuture<Void> getReadyFuture()
ISessiongetReadyFuture in interface ISessionpublic IFuture<Void> getCloseFuture()
ISessiongetCloseFuture in interface ISessionpublic IFuture<Void> getEndFuture()
ISessiongetEndFuture in interface ISessionpublic ISessionConfig getConfig()
ISessionpublic ICodecPipeline getCodecPipeline()
ISessiongetCodecPipeline in interface ISessionnull if the session does not
support itpublic SessionState getState()
ISessionpublic boolean isOpen()
ISessionIt is equal to:
return getState() == SessionState.OPEN
public void dirtyClose()
ISessiondirtyClose in interface ISessionpublic void suspendRead()
ISessionsuspendRead in interface ISessionpublic void suspendWrite()
ISessionsuspendWrite in interface ISessionpublic void resumeRead()
ISessionresumeRead in interface ISessionpublic void resumeWrite()
ISessionresumeWrite in interface ISessionpublic boolean isReadSuspended()
ISessionisReadSuspended in interface ISessiontrue if suspendedpublic boolean isWriteSuspended()
ISessionisWriteSuspended in interface ISessiontrue if suspendedpublic final long getReadBytes()
ISessiongetReadBytes in interface ISessionpublic final long getWrittenBytes()
ISessiongetWrittenBytes in interface ISessionpublic final double getReadBytesThroughput()
ISessiongetReadBytesThroughput in interface ISessionpublic final double getWrittenBytesThroughput()
ISessiongetWrittenBytesThroughput in interface ISessionpublic final long getCreationTime()
ISessiongetCreationTime in interface ISessionpublic final long getLastIoTime()
ISessiongetLastIoTime in interface ISessionpublic final long getLastReadTime()
ISessiongetLastReadTime in interface ISessionpublic final long getLastWriteTime()
ISessiongetLastWriteTime in interface ISessionpublic ISessionTimer getTimer()
ISessionpublic boolean isDataCopyingOptimized()
ISession
Checking this flag can be helpful in determining if a buffer allocated by the
ISession.allocate(int) method need to be released after passing it to the
session's write/send methods. For example, if the returned value is
true the buffer will be released automatically and so it should not
be released by a user's implementation.
isDataCopyingOptimized in interface ISessiontrue if the processing of data is optimizedISessionConfig.optimizeDataCopying()public ByteBuffer allocate(int capacity)
ISessionpublic void release(ByteBuffer buffer)
ISessionpublic IFuture<Void> execute(Runnable task)
ISessionpublic void executenf(Runnable task)
ISessionThis method should be used whenever there will be no need to synchronize on a future associated with the specified task. This will save some resources and may improve performance.
Copyright © 2017–2022 SNF4J.ORG. All rights reserved.