Top Fields Constructors Methods
org.apache.hc.core5.reactor

pack-priv final Class InternalDataChannel

extends InternalChannel
implements ProtocolIOSession
Class Inheritance
All Implemented Interfaces
org.apache.hc.core5.reactor.ProtocolIOSession, org.apache.hc.core5.reactor.ssl.TransportSecurityLayer, org.apache.hc.core5.reactor.IOSession, org.apache.hc.core5.util.Identifiable, org.apache.hc.core5.http.SocketModalCloseable, org.apache.hc.core5.io.ModalCloseable, java.io.Closeable, java.lang.AutoCloseable, java.nio.channels.ByteChannel, java.nio.channels.WritableByteChannel, java.nio.channels.Channel, java.nio.channels.ReadableByteChannel
Imports
java.io.IOException, java.net.SocketAddress, java.nio.ByteBuffer, java.nio.channels.ByteChannel, .SelectionKey, java.util.Queue, java.util.concurrent.ConcurrentHashMap, .ConcurrentMap, java.util.concurrent.atomic.AtomicBoolean, .AtomicReference, java.util.concurrent.locks.Lock, javax.net.ssl.SSLContext, .SSLSession, org.apache.hc.core5.concurrent.CallbackContribution, .FutureCallback, org.apache.hc.core5.function.Decorator, org.apache.hc.core5.io.CloseMode, org.apache.hc.core5.net.NamedEndpoint, org.apache.hc.core5.reactor.ssl.SSLBufferMode, .SSLIOSession, .SSLMode, .SSLSessionInitializer, .SSLSessionVerifier, .TlsDetails, .TransportSecurityLayer, org.apache.hc.core5.util.Args, .Asserts, .TextUtils, .Timeout

Field Summary

Modifier and TypeField and Description
private final AtomicBoolean
private final Queue<InternalDataChannel>
private final AtomicReference<IOSession>
private final AtomicReference<IOEventHandler>
private final NamedEndpoint
private final IOSession
private final Decorator<IOSession>
private final ConcurrentMap<String, ProtocolUpgradeHandler>
private final IOSessionListener
private final AtomicReference<SSLIOSession>

Constructor Summary

AccessConstructor and Description
pack-priv
InternalDataChannel(final IOSession ioSession, final NamedEndpoint initialEndpoint, final Decorator<IOSession> ioSessionDecorator, final IOSessionListener sessionListener, final Queue<InternalDataChannel> closedSessions)

Method Summary

Modifier and TypeMethod and Description
public ByteChannel
channel()

Implements org.apache.hc.core5.reactor.IOSession.channel.

Returns the underlying I/O channel associated with this session.
public void
clearEvent(final int
I/O event type.
op
)

Implements org.apache.hc.core5.reactor.IOSession.clearEvent.

Clears interest in a particular I/O event type by updating the event mask associated with the session.
public void
close()

Implements org.apache.hc.core5.reactor.IOSession.close, java.io.Closeable.close.

Terminates the session gracefully and closes the underlying I/O channel.
public void
close(final CloseMode
How to close the receiver.
closeMode
)

Implements org.apache.hc.core5.io.ModalCloseable.close.

Closes this process or endpoint and releases any system resources associated with it.
pack-priv void
public void
enqueue(final Command command, final Command.Priority priority)

Implements org.apache.hc.core5.reactor.IOSession.enqueue.

Inserts Command at the end of the command queue.
private IOEventHandler
ensureHandler(final IOSession session)

public int
getEventMask()

Implements org.apache.hc.core5.reactor.IOSession.getEventMask.

Returns mask of I/O evens this session declared interest in.
public IOEventHandler
getHandler()

Implements org.apache.hc.core5.reactor.IOSession.getHandler.

Returns event handler associated with the session.
public String
public NamedEndpoint
public long
getLastEventTime()

Implements abstract org.apache.hc.core5.reactor.InternalChannel.getLastEventTime.

Implements org.apache.hc.core5.reactor.IOSession.getLastEventTime.

Returns timestamp of the last I/O event including socket timeout reset.
public long
getLastReadTime()

Implements org.apache.hc.core5.reactor.IOSession.getLastReadTime.

Returns timestamp of the last read event.
public long
getLastWriteTime()

Implements org.apache.hc.core5.reactor.IOSession.getLastWriteTime.

Returns timestamp of the last write event.
public SocketAddress
public Lock
getLock()

Implements org.apache.hc.core5.reactor.IOSession.getLock.

Returns session lock that should be used by I/O event handlers to synchronize access to the session.
public SocketAddress
getRemoteAddress()

Implements org.apache.hc.core5.reactor.IOSession.getRemoteAddress.

Returns address of the remote peer.
public Timeout
getSocketTimeout()

Implements org.apache.hc.core5.reactor.IOSession.getSocketTimeout.

Returns value of the socket timeout in milliseconds.
public IOSession.Status
getStatus()

Implements org.apache.hc.core5.reactor.IOSession.getStatus.

Returns status of the session:

Status#ACTIVE: session is active.

pack-priv Timeout
public TlsDetails
getTlsDetails()

Implements org.apache.hc.core5.reactor.ssl.TransportSecurityLayer.getTlsDetails.

Returns details of a fully established TLS session.
public boolean
hasCommands()

Implements org.apache.hc.core5.reactor.IOSession.hasCommands.

Tests if there enqueued commands pending execution.
public boolean
isOpen()

Implements java.nio.channels.Channel.isOpen.

Tells whether or not this channel is open.
pack-priv void
pack-priv void
onIOEvent(final int readyOps)

Implements abstract org.apache.hc.core5.reactor.InternalChannel.onIOEvent.

pack-priv void
pack-priv void
onTLSSessionEnd(final SSLIOSession sslSession)

pack-priv void
onTLSSessionStart(final SSLIOSession sslSession)

public Command
poll()

Implements org.apache.hc.core5.reactor.IOSession.poll.

Removes first Command from the command queue if available.
public int
read(final ByteBuffer
The buffer into which bytes are to be transferred
dst
)

Implements java.nio.channels.ReadableByteChannel.read.

Reads a sequence of bytes from this channel into the given buffer.
public void
registerProtocol(final String
the application protocol ID
protocolId
,
final ProtocolUpgradeHandler
the upgrade handler.
upgradeHandler
)

Overrides default org.apache.hc.core5.reactor.ProtocolIOSession.registerProtocol.

Registers protocol upgrade handler with the given application protocol ID.
public void
setEvent(final int
I/O event type.
op
)

Implements org.apache.hc.core5.reactor.IOSession.setEvent.

Declares interest in a particular I/O event type by updating the event mask associated with the session.
public void
setEventMask(final int
new I/O event mask.
ops
)

Implements org.apache.hc.core5.reactor.IOSession.setEventMask.

Declares interest in I/O event notifications by setting the event mask associated with the session
public void
setSocketTimeout(final Timeout
socket timeout.
timeout
)

Implements org.apache.hc.core5.reactor.IOSession.setSocketTimeout.

Sets value of the socket timeout in milliseconds.
public void
startTls(final SSLContext
SSL context to be used for this session.
sslContext
,
final NamedEndpoint
optional endpoint details for outgoing client side connections.
endpoint
,
final SSLBufferMode
SSL buffer management mode.
sslBufferMode
,
final SSLSessionInitializer
SSL session initialization callback.
initializer
,
final SSLSessionVerifier
SSL session verification callback.
verifier
,
final Timeout
the timeout to use while performing the TLS handshake; may be null.
handshakeTimeout
)

Implements org.apache.hc.core5.reactor.ssl.TransportSecurityLayer.startTls.

Starts TLS session over an existing network connection with the given SSL context.
public void
startTls(final SSLContext
SSL context to be used for this session.
sslContext
,
final NamedEndpoint
optional endpoint details for outgoing client side connections.
endpoint
,
final SSLBufferMode
SSL buffer management mode.
sslBufferMode
,
final SSLSessionInitializer
SSL session initialization callback.
initializer
,
final SSLSessionVerifier
SSL session verification callback.
verifier
,
final Timeout
the timeout to use while performing the TLS handshake; may be null.
handshakeTimeout
,
final FutureCallback<TransportSecurityLayer> callback)

Overrides default org.apache.hc.core5.reactor.ssl.TransportSecurityLayer.startTls.

Starts TLS session over an existing network connection with the given SSL context.
public void
switchProtocol(final String
the application protocol ID
protocolId
,
final FutureCallback<ProtocolIOSession>
the result callback
callback
)

Overrides default org.apache.hc.core5.reactor.ProtocolIOSession.switchProtocol.

Switches this I/O session to the application protocol with the given ID.
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
public void
updateReadTime()

Implements org.apache.hc.core5.reactor.IOSession.updateReadTime.

Updates the timestamp of the last read event
public void
updateWriteTime()

Implements org.apache.hc.core5.reactor.IOSession.updateWriteTime.

Updates the timestamp of the last write event
public void
upgrade(final IOEventHandler handler)

Implements org.apache.hc.core5.reactor.IOSession.upgrade.

Upgrades event handler associated with the session.
public int
write(final ByteBuffer
The buffer from which bytes are to be retrieved
src
)

Implements java.nio.channels.WritableByteChannel.write.

Writes a sequence of bytes to this channel from the given buffer.
Inherited from org.apache.hc.core5.reactor.InternalChannel:
checkTimeouthandleIOEvent

Field Detail

closedback to summary
private final AtomicBoolean closed
closedSessionsback to summary
private final Queue<InternalDataChannel> closedSessions
currentSessionRefback to summary
private final AtomicReference<IOSession> currentSessionRef
eventHandlerRefback to summary
private final AtomicReference<IOEventHandler> eventHandlerRef
initialEndpointback to summary
private final NamedEndpoint initialEndpoint
ioSessionback to summary
private final IOSession ioSession
ioSessionDecoratorback to summary
private final Decorator<IOSession> ioSessionDecorator
protocolUpgradeHandlerMapback to summary
private final ConcurrentMap<String, ProtocolUpgradeHandler> protocolUpgradeHandlerMap
sessionListenerback to summary
private final IOSessionListener sessionListener
tlsSessionRefback to summary
private final AtomicReference<SSLIOSession> tlsSessionRef

Constructor Detail

InternalDataChannelback to summary
pack-priv InternalDataChannel(final IOSession ioSession, final NamedEndpoint initialEndpoint, final Decorator<IOSession> ioSessionDecorator, final IOSessionListener sessionListener, final Queue<InternalDataChannel> closedSessions)

Method Detail

channelback to summary
public ByteChannel channel()

Implements org.apache.hc.core5.reactor.IOSession.channel.

Doc from org.apache.hc.core5.reactor.IOSession.channel.

Returns the underlying I/O channel associated with this session.

Returns:ByteChannel

the I/O channel.

Annotations
@Override
clearEventback to summary
public void clearEvent(final int op)

Implements org.apache.hc.core5.reactor.IOSession.clearEvent.

Doc from org.apache.hc.core5.reactor.IOSession.clearEvent.

Clears interest in a particular I/O event type by updating the event mask associated with the session.

Parameters
op:int

I/O event type.

Annotations
@Override
closeback to summary
public void close()

Implements org.apache.hc.core5.reactor.IOSession.close, java.io.Closeable.close.

Doc from org.apache.hc.core5.reactor.IOSession.close.

Terminates the session gracefully and closes the underlying I/O channel. This method ensures that session termination handshake, such as the one used by the SSL/TLS protocol, is correctly carried out.

Annotations
@Override
closeback to summary
public void close(final CloseMode closeMode)

Implements org.apache.hc.core5.io.ModalCloseable.close.

Doc from org.apache.hc.core5.io.ModalCloseable.close.

Closes this process or endpoint and releases any system resources associated with it. If the endpoint or the process is already closed then invoking this method has no effect.

Parameters
closeMode:CloseMode

How to close the receiver.

Annotations
@Override
disconnectedback to summary
pack-priv void disconnected()
enqueueback to summary
public void enqueue(final Command command, final Command.Priority priority)

Implements org.apache.hc.core5.reactor.IOSession.enqueue.

Doc from org.apache.hc.core5.reactor.IOSession.enqueue.

Inserts Command at the end of the command queue.

Annotations
@Override
ensureHandlerback to summary
private IOEventHandler ensureHandler(final IOSession session)
getEventMaskback to summary
public int getEventMask()

Implements org.apache.hc.core5.reactor.IOSession.getEventMask.

Doc from org.apache.hc.core5.reactor.IOSession.getEventMask.

Returns mask of I/O evens this session declared interest in.

Returns:int

I/O event mask.

Annotations
@Override
getHandlerback to summary
public IOEventHandler getHandler()

Implements org.apache.hc.core5.reactor.IOSession.getHandler.

Doc from org.apache.hc.core5.reactor.IOSession.getHandler.

Returns event handler associated with the session.

Annotations
@Override
getIdback to summary
public String getId()

Implements org.apache.hc.core5.util.Identifiable.getId.

Annotations
@Override
getInitialEndpointback to summary
public NamedEndpoint getInitialEndpoint()

Implements org.apache.hc.core5.reactor.ProtocolIOSession.getInitialEndpoint.

Annotations
@Override
getLastEventTimeback to summary
public long getLastEventTime()

Implements abstract org.apache.hc.core5.reactor.InternalChannel.getLastEventTime.

Implements org.apache.hc.core5.reactor.IOSession.getLastEventTime.

Doc from org.apache.hc.core5.reactor.IOSession.getLastEventTime.

Returns timestamp of the last I/O event including socket timeout reset.

Returns:long

timestamp.

Annotations
@Override
getLastReadTimeback to summary
public long getLastReadTime()

Implements org.apache.hc.core5.reactor.IOSession.getLastReadTime.

Doc from org.apache.hc.core5.reactor.IOSession.getLastReadTime.

Returns timestamp of the last read event.

Returns:long

timestamp.

Annotations
@Override
getLastWriteTimeback to summary
public long getLastWriteTime()

Implements org.apache.hc.core5.reactor.IOSession.getLastWriteTime.

Doc from org.apache.hc.core5.reactor.IOSession.getLastWriteTime.

Returns timestamp of the last write event.

Returns:long

timestamp.

Annotations
@Override
getLocalAddressback to summary
public SocketAddress getLocalAddress()

Implements org.apache.hc.core5.reactor.IOSession.getLocalAddress.

Doc from org.apache.hc.core5.reactor.IOSession.getLocalAddress.

Returns local address.

Returns:SocketAddress

socket address.

Annotations
@Override
getLockback to summary
public Lock getLock()

Implements org.apache.hc.core5.reactor.IOSession.getLock.

Doc from org.apache.hc.core5.reactor.IOSession.getLock.

Returns session lock that should be used by I/O event handlers to synchronize access to the session.

Annotations
@Override
getRemoteAddressback to summary
public SocketAddress getRemoteAddress()

Implements org.apache.hc.core5.reactor.IOSession.getRemoteAddress.

Doc from org.apache.hc.core5.reactor.IOSession.getRemoteAddress.

Returns address of the remote peer.

Returns:SocketAddress

socket address.

Annotations
@Override
getSocketTimeoutback to summary
public Timeout getSocketTimeout()

Implements org.apache.hc.core5.reactor.IOSession.getSocketTimeout.

Doc from org.apache.hc.core5.reactor.IOSession.getSocketTimeout.

Returns value of the socket timeout in milliseconds. The value of 0 signifies the session cannot time out.

Returns:Timeout

socket timeout.

Annotations
@Override
getStatusback to summary
public IOSession.Status getStatus()

Implements org.apache.hc.core5.reactor.IOSession.getStatus.

Doc from org.apache.hc.core5.reactor.IOSession.getStatus.

Returns status of the session:

Status#ACTIVE: session is active.

Status#CLOSING: session is being closed.

Status#CLOSED: session has been terminated.

Returns:IOSession.Status

session status.

Annotations
@Override
getTimeoutback to summary
pack-priv Timeout getTimeout()

Implements abstract org.apache.hc.core5.reactor.InternalChannel.getTimeout.

Annotations
@Override
getTlsDetailsback to summary
public TlsDetails getTlsDetails()

Implements org.apache.hc.core5.reactor.ssl.TransportSecurityLayer.getTlsDetails.

Doc from org.apache.hc.core5.reactor.ssl.TransportSecurityLayer.getTlsDetails.

Returns details of a fully established TLS session.

Returns:TlsDetails

TLS session details.

Annotations
@SuppressWarnings:resource
@Override
hasCommandsback to summary
public boolean hasCommands()

Implements org.apache.hc.core5.reactor.IOSession.hasCommands.

Doc from org.apache.hc.core5.reactor.IOSession.hasCommands.

Tests if there enqueued commands pending execution.

Annotations
@Override
isOpenback to summary
public boolean isOpen()

Implements java.nio.channels.Channel.isOpen.

Doc from java.nio.channels.Channel.isOpen.

Tells whether or not this channel is open.

Returns:boolean

true if, and only if, this channel is open

Annotations
@Override
onExceptionback to summary
pack-priv void onException(final Exception cause)

Implements abstract org.apache.hc.core5.reactor.InternalChannel.onException.

Annotations
@Override
onIOEventback to summary
pack-priv void onIOEvent(final int readyOps) throws IOException

Implements abstract org.apache.hc.core5.reactor.InternalChannel.onIOEvent.

Annotations
@Override
onTimeoutback to summary
pack-priv void onTimeout(final Timeout timeout) throws IOException

Implements abstract org.apache.hc.core5.reactor.InternalChannel.onTimeout.

Annotations
@Override
onTLSSessionEndback to summary
pack-priv void onTLSSessionEnd(final SSLIOSession sslSession)
onTLSSessionStartback to summary
pack-priv void onTLSSessionStart(final SSLIOSession sslSession)
pollback to summary
public Command poll()

Implements org.apache.hc.core5.reactor.IOSession.poll.

Doc from org.apache.hc.core5.reactor.IOSession.poll.

Removes first Command from the command queue if available.

Annotations
@Override
readback to summary
public int read(final ByteBuffer dst) throws IOException

Implements java.nio.channels.ReadableByteChannel.read.

Doc from java.nio.channels.ReadableByteChannel.read.

Reads a sequence of bytes from this channel into the given buffer.

An attempt is made to read up to r bytes from the channel, where r is the number of bytes remaining in the buffer, that is, dst.remaining(), at the moment this method is invoked.

Suppose that a byte sequence of length n is read, where 0 <= n <= r. This byte sequence will be transferred into the buffer so that the first byte in the sequence is at index p and the last byte is at index p + n - 1, where p is the buffer's position at the moment this method is invoked. Upon return the buffer's position will be equal to p + n; its limit will not have changed.

A read operation might not fill the buffer, and in fact it might not read any bytes at all. Whether or not it does so depends upon the nature and state of the channel. A socket channel in non-blocking mode, for example, cannot read any more bytes than are immediately available from the socket's input buffer; similarly, a file channel cannot read any more bytes than remain in the file. It is guaranteed, however, that if a channel is in blocking mode and there is at least one byte remaining in the buffer then this method will block until at least one byte is read.

This method may be invoked at any time. If another thread has already initiated a read operation upon this channel, however, then an invocation of this method will block until the first operation is complete.

Parameters
dst:ByteBuffer

The buffer into which bytes are to be transferred

Returns:int

The number of bytes read, possibly zero, or -1 if the channel has reached end-of-stream

Annotations
@Override
Exceptions
IOException:
If some other I/O error occurs
registerProtocolback to summary
public void registerProtocol(final String protocolId, final ProtocolUpgradeHandler upgradeHandler)

Overrides default org.apache.hc.core5.reactor.ProtocolIOSession.registerProtocol.

Doc from org.apache.hc.core5.reactor.ProtocolIOSession.registerProtocol.

Registers protocol upgrade handler with the given application protocol ID.

Parameters
protocolId:String

the application protocol ID

upgradeHandler:ProtocolUpgradeHandler

the upgrade handler.

Annotations
@Override
setEventback to summary
public void setEvent(final int op)

Implements org.apache.hc.core5.reactor.IOSession.setEvent.

Doc from org.apache.hc.core5.reactor.IOSession.setEvent.

Declares interest in a particular I/O event type by updating the event mask associated with the session.

Parameters
op:int

I/O event type.

Annotations
@Override
setEventMaskback to summary
public void setEventMask(final int ops)

Implements org.apache.hc.core5.reactor.IOSession.setEventMask.

Doc from org.apache.hc.core5.reactor.IOSession.setEventMask.

Declares interest in I/O event notifications by setting the event mask associated with the session

Parameters
ops:int

new I/O event mask.

Annotations
@Override
setSocketTimeoutback to summary
public void setSocketTimeout(final Timeout timeout)

Implements org.apache.hc.core5.reactor.IOSession.setSocketTimeout.

Doc from org.apache.hc.core5.reactor.IOSession.setSocketTimeout.

Sets value of the socket timeout in milliseconds. The value of 0 signifies the session cannot time out.

Please note this operation may affect the last event time.

Parameters
timeout:Timeout

socket timeout.

Annotations
@Override
startTlsback to summary
public void startTls(final SSLContext sslContext, final NamedEndpoint endpoint, final SSLBufferMode sslBufferMode, final SSLSessionInitializer initializer, final SSLSessionVerifier verifier, final Timeout handshakeTimeout)

Implements org.apache.hc.core5.reactor.ssl.TransportSecurityLayer.startTls.

Doc from org.apache.hc.core5.reactor.ssl.TransportSecurityLayer.startTls.

Starts TLS session over an existing network connection with the given SSL context. NamedEndpoint details are applicable for client side connections and are used for host name verification, when supported by the SSL engine.

Parameters
sslContext:SSLContext

SSL context to be used for this session.

endpoint:NamedEndpoint

optional endpoint details for outgoing client side connections.

sslBufferMode:SSLBufferMode

SSL buffer management mode.

initializer:SSLSessionInitializer

SSL session initialization callback.

verifier:SSLSessionVerifier

SSL session verification callback.

handshakeTimeout:Timeout

the timeout to use while performing the TLS handshake; may be null.

Annotations
@Override
startTlsback to summary
public void startTls(final SSLContext sslContext, final NamedEndpoint endpoint, final SSLBufferMode sslBufferMode, final SSLSessionInitializer initializer, final SSLSessionVerifier verifier, final Timeout handshakeTimeout, final FutureCallback<TransportSecurityLayer> callback)

Overrides default org.apache.hc.core5.reactor.ssl.TransportSecurityLayer.startTls.

Doc from org.apache.hc.core5.reactor.ssl.TransportSecurityLayer.startTls.

Starts TLS session over an existing network connection with the given SSL context. NamedEndpoint details are applicable for client side connections and are used for host name verification, when supported by the SSL engine.

Parameters
sslContext:SSLContext

SSL context to be used for this session.

endpoint:NamedEndpoint

optional endpoint details for outgoing client side connections.

sslBufferMode:SSLBufferMode

SSL buffer management mode.

initializer:SSLSessionInitializer

SSL session initialization callback.

verifier:SSLSessionVerifier

SSL session verification callback.

handshakeTimeout:Timeout

the timeout to use while performing the TLS handshake; may be null.

Annotations
@Override
switchProtocolback to summary
public void switchProtocol(final String protocolId, final FutureCallback<ProtocolIOSession> callback)

Overrides default org.apache.hc.core5.reactor.ProtocolIOSession.switchProtocol.

Doc from org.apache.hc.core5.reactor.ProtocolIOSession.switchProtocol.

Switches this I/O session to the application protocol with the given ID.

Parameters
protocolId:String

the application protocol ID

callback:FutureCallback<ProtocolIOSession>

the result callback

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override
updateReadTimeback to summary
public void updateReadTime()

Implements org.apache.hc.core5.reactor.IOSession.updateReadTime.

Doc from org.apache.hc.core5.reactor.IOSession.updateReadTime.

Updates the timestamp of the last read event

Annotations
@Override
updateWriteTimeback to summary
public void updateWriteTime()

Implements org.apache.hc.core5.reactor.IOSession.updateWriteTime.

Doc from org.apache.hc.core5.reactor.IOSession.updateWriteTime.

Updates the timestamp of the last write event

Annotations
@Override
upgradeback to summary
public void upgrade(final IOEventHandler handler)

Implements org.apache.hc.core5.reactor.IOSession.upgrade.

Doc from org.apache.hc.core5.reactor.IOSession.upgrade.

Upgrades event handler associated with the session.

Annotations
@Override
writeback to summary
public int write(final ByteBuffer src) throws IOException

Implements java.nio.channels.WritableByteChannel.write.

Doc from java.nio.channels.WritableByteChannel.write.

Writes a sequence of bytes to this channel from the given buffer.

An attempt is made to write up to r bytes to the channel, where r is the number of bytes remaining in the buffer, that is, src.remaining(), at the moment this method is invoked.

Suppose that a byte sequence of length n is written, where 0 <= n <= r. This byte sequence will be transferred from the buffer starting at index p, where p is the buffer's position at the moment this method is invoked; the index of the last byte written will be p + n - 1. Upon return the buffer's position will be equal to p + n; its limit will not have changed.

Unless otherwise specified, a write operation will return only after writing all of the r requested bytes. Some types of channels, depending upon their state, may write only some of the bytes or possibly none at all. A socket channel in non-blocking mode, for example, cannot write any more bytes than are free in the socket's output buffer.

This method may be invoked at any time. If another thread has already initiated a write operation upon this channel, however, then an invocation of this method will block until the first operation is complete.

Parameters
src:ByteBuffer

The buffer from which bytes are to be retrieved

Returns:int

The number of bytes written, possibly zero

Annotations
@Override
Exceptions
IOException:
If some other I/O error occurs