public class SocketSend extends AsynchronousSocketStep
AsynchronousSocketChannel
.AsynchronousChannelStep.ChannelCallback<V,C extends java.nio.channels.AsynchronousChannel>, AsynchronousChannelStep.ChannelOperation<C extends java.nio.channels.AsynchronousChannel>
SOCKET_CHANNEL
CHANNEL_GROUP
Constructor and Description |
---|
SocketSend(java.util.function.Function<Continuation<?>,java.net.SocketAddress> fGetSocketAddress)
Creates a new instance.
|
Modifier and Type | Method and Description |
---|---|
protected boolean |
performAsyncOperation(int nBytesSent,
java.nio.channels.AsynchronousSocketChannel rChannel,
java.nio.ByteBuffer rData,
AsynchronousChannelStep.ChannelCallback<java.lang.Integer,java.nio.channels.AsynchronousSocketChannel> rCallback)
Implementation of the ChannelOperation functional interface method
signature.
|
protected void |
performBlockingOperation(java.nio.channels.AsynchronousSocketChannel aChannel,
java.nio.ByteBuffer rData)
Must be implemented for the blocking execution of a step.
|
static SocketSend |
sendTo(java.util.function.Function<Continuation<?>,java.net.SocketAddress> fGetSocketAddress)
Suspends until all data from the input
ByteBuffer has been sent
to a network socket.The buffer must be initialized for sending, i.e. if
necessary a call to Buffer.flip() must have been performed. |
static SocketSend |
sendTo(java.net.SocketAddress rSocketAddress) |
execute, getSocketAddress, getSocketAddressFactory, getSocketChannel, runAsync
getChannelGroup
fail, runBlocking, terminateCoroutine, toString
deleteRelation, get, getRelation, getRelations, notifyRelationListeners, readRelations, relationsEqual, relationsHashCode, relationsString, set, set, transform, writeRelations
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
public SocketSend(java.util.function.Function<Continuation<?>,java.net.SocketAddress> fGetSocketAddress)
fGetSocketAddress
- A function that provides the target socket
address from the current continuationpublic static SocketSend sendTo(java.util.function.Function<Continuation<?>,java.net.SocketAddress> fGetSocketAddress)
ByteBuffer
has been sent
to a network socket.The buffer must be initialized for sending, i.e. if
necessary a call to Buffer.flip()
must have been performed.
After the data has been fully sent Buffer.clear()
will be
invoked on the buffer so that it can be used directly for subsequent
writing to it. An example would be a following SocketReceive
to
implement a request-response scheme.
fGetSocketAddress
- A function that provides the target socket
address from the current continuationpublic static SocketSend sendTo(java.net.SocketAddress rSocketAddress)
sendTo(Function)
protected boolean performAsyncOperation(int nBytesSent, java.nio.channels.AsynchronousSocketChannel rChannel, java.nio.ByteBuffer rData, AsynchronousChannelStep.ChannelCallback<java.lang.Integer,java.nio.channels.AsynchronousSocketChannel> rCallback)
protected void performBlockingOperation(java.nio.channels.AsynchronousSocketChannel aChannel, java.nio.ByteBuffer rData) throws java.lang.InterruptedException, java.util.concurrent.ExecutionException
AsynchronousSocketChannel
which must be accessed through the
blocking API (like Future.get()
).performBlockingOperation
in class AsynchronousSocketStep
aChannel
- The channel to perform the operation onrData
- The byte buffer for the operation datajava.lang.InterruptedException
java.util.concurrent.ExecutionException