AsynchronousSocketChannel (Java Platform SE 8 ) (original) (raw)
Method Detail
provider
public final AsynchronousChannelProvider provider()
Returns the provider that created this channel.
Returns:
The provider that created this channel
open
public static AsynchronousSocketChannel open(AsynchronousChannelGroup group)
throws IOException
Opens an asynchronous socket channel.
The new channel is created by invoking the openAsynchronousSocketChannel method on the AsynchronousChannelProvider that created the group. If the group parameter is null
then the resulting channel is created by the system-wide default provider, and bound to the default group.
Parameters:group
- The group to which the newly constructed channel should be bound, or null
for the default group
Returns:
A new asynchronous socket channel
Throws:[ShutdownChannelGroupException](../../../java/nio/channels/ShutdownChannelGroupException.html "class in java.nio.channels")
- If the channel group is shutdown[IOException](../../../java/io/IOException.html "class in java.io")
- If an I/O error occurs
open
public static AsynchronousSocketChannel open()
throws IOException
Opens an asynchronous socket channel.
This method returns an asynchronous socket channel that is bound to the default group.This method is equivalent to evaluating the expression:
open((AsynchronousChannelGroup)null);
Returns:
A new asynchronous socket channel
Throws:[IOException](../../../java/io/IOException.html "class in java.io")
- If an I/O error occurs
bind
public abstract AsynchronousSocketChannel bind(SocketAddress local)
throws IOException
Binds the channel's socket to a local address.
This method is used to establish an association between the socket and a local address. Once an association is established then the socket remains bound until the channel is closed. If the local
parameter has the value null
then the socket will be bound to an address that is assigned automatically.
Specified by:[bind](../../../java/nio/channels/NetworkChannel.html#bind-java.net.SocketAddress-)
in interface [NetworkChannel](../../../java/nio/channels/NetworkChannel.html "interface in java.nio.channels")
Parameters:local
- The address to bind the socket, or null
to bind the socket to an automatically assigned socket address
Returns:
This channel
Throws:[ConnectionPendingException](../../../java/nio/channels/ConnectionPendingException.html "class in java.nio.channels")
- If a connection operation is already in progress on this channel[AlreadyBoundException](../../../java/nio/channels/AlreadyBoundException.html "class in java.nio.channels")
- If the socket is already bound[UnsupportedAddressTypeException](../../../java/nio/channels/UnsupportedAddressTypeException.html "class in java.nio.channels")
- If the type of the given address is not supported[ClosedChannelException](../../../java/nio/channels/ClosedChannelException.html "class in java.nio.channels")
- If the channel is closed[IOException](../../../java/io/IOException.html "class in java.io")
- If some other I/O error occurs[SecurityException](../../../java/lang/SecurityException.html "class in java.lang")
- If a security manager has been installed and itscheckListen method denies the operation
See Also:
NetworkChannel.getLocalAddress()
setOption
public abstract AsynchronousSocketChannel setOption(SocketOption name,
T value)
throws IOException
Sets the value of a socket option.
Specified by:[setOption](../../../java/nio/channels/NetworkChannel.html#setOption-java.net.SocketOption-T-)
in interface [NetworkChannel](../../../java/nio/channels/NetworkChannel.html "interface in java.nio.channels")
Type Parameters:T
- The type of the socket option value
Parameters:name
- The socket optionvalue
- The value of the socket option. A value of null
may be a valid value for some socket options.
Returns:
This channel
Throws:[IllegalArgumentException](../../../java/lang/IllegalArgumentException.html "class in java.lang")
- If the value is not a valid value for this socket option[ClosedChannelException](../../../java/nio/channels/ClosedChannelException.html "class in java.nio.channels")
- If this channel is closed[IOException](../../../java/io/IOException.html "class in java.io")
- If an I/O error occurs
See Also:
StandardSocketOptions
shutdownInput
public abstract AsynchronousSocketChannel shutdownInput()
throws IOException
Shutdown the connection for reading without closing the channel.
Once shutdown for reading then further reads on the channel will return -1
, the end-of-stream indication. If the input side of the connection is already shutdown then invoking this method has no effect. The effect on an outstanding read operation is system dependent and therefore not specified. The effect, if any, when there is data in the socket receive buffer that has not been read, or data arrives subsequently, is also system dependent.
Returns:
The channel
Throws:[NotYetConnectedException](../../../java/nio/channels/NotYetConnectedException.html "class in java.nio.channels")
- If this channel is not yet connected[ClosedChannelException](../../../java/nio/channels/ClosedChannelException.html "class in java.nio.channels")
- If this channel is closed[IOException](../../../java/io/IOException.html "class in java.io")
- If some other I/O error occurs
shutdownOutput
public abstract AsynchronousSocketChannel shutdownOutput()
throws IOException
Shutdown the connection for writing without closing the channel.
Once shutdown for writing then further attempts to write to the channel will throw ClosedChannelException. If the output side of the connection is already shutdown then invoking this method has no effect. The effect on an outstanding write operation is system dependent and therefore not specified.
Returns:
The channel
Throws:[NotYetConnectedException](../../../java/nio/channels/NotYetConnectedException.html "class in java.nio.channels")
- If this channel is not yet connected[ClosedChannelException](../../../java/nio/channels/ClosedChannelException.html "class in java.nio.channels")
- If this channel is closed[IOException](../../../java/io/IOException.html "class in java.io")
- If some other I/O error occurs
getRemoteAddress
public abstract SocketAddress getRemoteAddress()
throws IOException
Returns the remote address to which this channel's socket is connected.
Where the channel is bound and connected to an Internet Protocol socket address then the return value from this method is of type InetSocketAddress.
Returns:
The remote address; null
if the channel's socket is not connected
Throws:[ClosedChannelException](../../../java/nio/channels/ClosedChannelException.html "class in java.nio.channels")
- If the channel is closed[IOException](../../../java/io/IOException.html "class in java.io")
- If an I/O error occurs
connect
public abstract void connect(SocketAddress remote,
A attachment,
CompletionHandler<Void,? super A> handler)
Connects this channel.
This method initiates an operation to connect this channel. Thehandler
parameter is a completion handler that is invoked when the connection is successfully established or connection cannot be established. If the connection cannot be established then the channel is closed.
This method performs exactly the same security checks as the Socket class. That is, if a security manager has been installed then this method verifies that its checkConnect method permits connecting to the address and port number of the given remote endpoint.
Type Parameters:A
- The type of the attachment
Parameters:remote
- The remote address to which this channel is to be connectedattachment
- The object to attach to the I/O operation; can be null
handler
- The handler for consuming the result
Throws:[UnresolvedAddressException](../../../java/nio/channels/UnresolvedAddressException.html "class in java.nio.channels")
- If the given remote address is not fully resolved[UnsupportedAddressTypeException](../../../java/nio/channels/UnsupportedAddressTypeException.html "class in java.nio.channels")
- If the type of the given remote address is not supported[AlreadyConnectedException](../../../java/nio/channels/AlreadyConnectedException.html "class in java.nio.channels")
- If this channel is already connected[ConnectionPendingException](../../../java/nio/channels/ConnectionPendingException.html "class in java.nio.channels")
- If a connection operation is already in progress on this channel[ShutdownChannelGroupException](../../../java/nio/channels/ShutdownChannelGroupException.html "class in java.nio.channels")
- If the channel group has terminated[SecurityException](../../../java/lang/SecurityException.html "class in java.lang")
- If a security manager has been installed and it does not permit access to the given remote endpoint
See Also:
getRemoteAddress()
connect
public abstract Future<Void> connect(SocketAddress remote)
Connects this channel.
This method initiates an operation to connect this channel. This method behaves in exactly the same manner as the connect(SocketAddress, Object, CompletionHandler) method except that instead of specifying a completion handler, this method returns a Future
representing the pending result. The Future
's get method returns null
on successful completion.
Parameters:remote
- The remote address to which this channel is to be connected
Returns:
A Future
object representing the pending result
Throws:[UnresolvedAddressException](../../../java/nio/channels/UnresolvedAddressException.html "class in java.nio.channels")
- If the given remote address is not fully resolved[UnsupportedAddressTypeException](../../../java/nio/channels/UnsupportedAddressTypeException.html "class in java.nio.channels")
- If the type of the given remote address is not supported[AlreadyConnectedException](../../../java/nio/channels/AlreadyConnectedException.html "class in java.nio.channels")
- If this channel is already connected[ConnectionPendingException](../../../java/nio/channels/ConnectionPendingException.html "class in java.nio.channels")
- If a connection operation is already in progress on this channel[SecurityException](../../../java/lang/SecurityException.html "class in java.lang")
- If a security manager has been installed and it does not permit access to the given remote endpoint
read
public abstract void read(ByteBuffer dst,
long timeout,
TimeUnit unit,
A attachment,
CompletionHandler<Integer,? super A> handler)
Reads a sequence of bytes from this channel into the given buffer.
This method initiates an asynchronous read operation to read a sequence of bytes from this channel into the given buffer. The handler
parameter is a completion handler that is invoked when the read operation completes (or fails). The result passed to the completion handler is the number of bytes read or -1
if no bytes could be read because the channel has reached end-of-stream.
If a timeout is specified and the timeout elapses before the operation completes then the operation completes with the exception InterruptedByTimeoutException. Where a timeout occurs, and the implementation cannot guarantee that bytes have not been read, or will not be read from the channel into the given buffer, then further attempts to read from the channel will cause an unspecific runtime exception to be thrown.
Otherwise this method works in the same manner as the AsynchronousByteChannel.read(ByteBuffer,Object,CompletionHandler) method.
Type Parameters:A
- The type of the attachment
Parameters:dst
- The buffer into which bytes are to be transferredtimeout
- The maximum time for the I/O operation to completeunit
- The time unit of the timeout
argumentattachment
- The object to attach to the I/O operation; can be null
handler
- The handler for consuming the result
Throws:[IllegalArgumentException](../../../java/lang/IllegalArgumentException.html "class in java.lang")
- If the buffer is read-only[ReadPendingException](../../../java/nio/channels/ReadPendingException.html "class in java.nio.channels")
- If a read operation is already in progress on this channel[NotYetConnectedException](../../../java/nio/channels/NotYetConnectedException.html "class in java.nio.channels")
- If this channel is not yet connected[ShutdownChannelGroupException](../../../java/nio/channels/ShutdownChannelGroupException.html "class in java.nio.channels")
- If the channel group has terminated
read
public final void read(ByteBuffer dst,
A attachment,
CompletionHandler<Integer,? super A> handler)
Reads a sequence of bytes from this channel into the given buffer.
This method initiates an asynchronous read operation to read a sequence of bytes from this channel into the given buffer. The handler
parameter is a completion handler that is invoked when the read operation completes (or fails). The result passed to the completion handler is the number of bytes read or -1
if no bytes could be read because the channel has reached end-of-stream.
The read operation may 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 time that the read is attempted. Where_r_ is 0, the read operation completes immediately with a result of0
without initiating an I/O operation.
Suppose that a byte sequence of length n is read, where0 < 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 the read is performed. Upon completion the buffer's position will be equal to_p_ + n; its limit will not have changed.
Buffers are not safe for use by multiple concurrent threads so care should be taken to not access the buffer until the operation has completed.
This method may be invoked at any time. Some channel types may not allow more than one read to be outstanding at any given time. If a thread initiates a read operation before a previous read operation has completed then a ReadPendingException will be thrown.
Specified by:[read](../../../java/nio/channels/AsynchronousByteChannel.html#read-java.nio.ByteBuffer-A-java.nio.channels.CompletionHandler-)
in interface [AsynchronousByteChannel](../../../java/nio/channels/AsynchronousByteChannel.html "interface in java.nio.channels")
Type Parameters:A
- The type of the attachment
Parameters:dst
- The buffer into which bytes are to be transferredattachment
- The object to attach to the I/O operation; can be null
handler
- The completion handler
Throws:[IllegalArgumentException](../../../java/lang/IllegalArgumentException.html "class in java.lang")
- If the buffer is read-only[ReadPendingException](../../../java/nio/channels/ReadPendingException.html "class in java.nio.channels")
- If the channel does not allow more than one read to be outstanding and a previous read has not completed[NotYetConnectedException](../../../java/nio/channels/NotYetConnectedException.html "class in java.nio.channels")
- If this channel is not yet connected[ShutdownChannelGroupException](../../../java/nio/channels/ShutdownChannelGroupException.html "class in java.nio.channels")
- If the channel group has terminated
read
public abstract Future<Integer> read(ByteBuffer dst)
Reads a sequence of bytes from this channel into the given buffer.
This method initiates an asynchronous read operation to read a sequence of bytes from this channel into the given buffer. The method behaves in exactly the same manner as the read(ByteBuffer,Object,CompletionHandler) method except that instead of specifying a completion handler, this method returns a Future
representing the pending result. The Future
's get method returns the number of bytes read or -1
if no bytes could be read because the channel has reached end-of-stream.
Specified by:[read](../../../java/nio/channels/AsynchronousByteChannel.html#read-java.nio.ByteBuffer-)
in interface [AsynchronousByteChannel](../../../java/nio/channels/AsynchronousByteChannel.html "interface in java.nio.channels")
Parameters:dst
- The buffer into which bytes are to be transferred
Returns:
A Future representing the result of the operation
Throws:[IllegalArgumentException](../../../java/lang/IllegalArgumentException.html "class in java.lang")
- If the buffer is read-only[ReadPendingException](../../../java/nio/channels/ReadPendingException.html "class in java.nio.channels")
- If the channel does not allow more than one read to be outstanding and a previous read has not completed[NotYetConnectedException](../../../java/nio/channels/NotYetConnectedException.html "class in java.nio.channels")
- If this channel is not yet connected
read
public abstract void read(ByteBuffer[] dsts,
int offset,
int length,
long timeout,
TimeUnit unit,
A attachment,
CompletionHandler<Long,? super A> handler)
Reads a sequence of bytes from this channel into a subsequence of the given buffers. This operation, sometimes called a scattering read, is often useful when implementing network protocols that group data into segments consisting of one or more fixed-length headers followed by a variable-length body. The handler
parameter is a completion handler that is invoked when the read operation completes (or fails). The result passed to the completion handler is the number of bytes read or-1
if no bytes could be read because the channel has reached end-of-stream.
This method initiates a read of up to r bytes from this channel, where r is the total number of bytes remaining in the specified subsequence of the given buffer array, that is,
dsts[offset].remaining()
+ dsts[offset+1].remaining()
+ ... + dsts[offset+length-1].remaining()
at the moment that the read is attempted.
Suppose that a byte sequence of length n is read, where0 < n <= r. Up to the first dsts[offset].remaining() bytes of this sequence are transferred into buffer dsts[offset], up to the nextdsts[offset+1].remaining() bytes are transferred into bufferdsts[offset+1], and so forth, until the entire byte sequence is transferred into the given buffers. As many bytes as possible are transferred into each buffer, hence the final position of each updated buffer, except the last updated buffer, is guaranteed to be equal to that buffer's limit. The underlying operating system may impose a limit on the number of buffers that may be used in an I/O operation. Where the number of buffers (with bytes remaining), exceeds this limit, then the I/O operation is performed with the maximum number of buffers allowed by the operating system.
If a timeout is specified and the timeout elapses before the operation completes then it completes with the exception InterruptedByTimeoutException. Where a timeout occurs, and the implementation cannot guarantee that bytes have not been read, or will not be read from the channel into the given buffers, then further attempts to read from the channel will cause an unspecific runtime exception to be thrown.
Type Parameters:A
- The type of the attachment
Parameters:dsts
- The buffers into which bytes are to be transferredoffset
- The offset within the buffer array of the first buffer into which bytes are to be transferred; must be non-negative and no larger thandsts.length
length
- The maximum number of buffers to be accessed; must be non-negative and no larger thandsts.length - offset
timeout
- The maximum time for the I/O operation to completeunit
- The time unit of thetimeout
argumentattachment
- The object to attach to the I/O operation; can benull
handler
- The handler for consuming the result
Throws:[IndexOutOfBoundsException](../../../java/lang/IndexOutOfBoundsException.html "class in java.lang")
- If the pre-conditions for theoffset
andlength
parameter aren't met[IllegalArgumentException](../../../java/lang/IllegalArgumentException.html "class in java.lang")
- If the buffer is read-only[ReadPendingException](../../../java/nio/channels/ReadPendingException.html "class in java.nio.channels")
- If a read operation is already in progress on this channel[NotYetConnectedException](../../../java/nio/channels/NotYetConnectedException.html "class in java.nio.channels")
- If this channel is not yet connected[ShutdownChannelGroupException](../../../java/nio/channels/ShutdownChannelGroupException.html "class in java.nio.channels")
- If the channel group has terminated
write
public abstract void write(ByteBuffer src,
long timeout,
TimeUnit unit,
A attachment,
CompletionHandler<Integer,? super A> handler)
Writes a sequence of bytes to this channel from the given buffer.
This method initiates an asynchronous write operation to write a sequence of bytes to this channel from the given buffer. The handler
parameter is a completion handler that is invoked when the write operation completes (or fails). The result passed to the completion handler is the number of bytes written.
If a timeout is specified and the timeout elapses before the operation completes then it completes with the exception InterruptedByTimeoutException. Where a timeout occurs, and the implementation cannot guarantee that bytes have not been written, or will not be written to the channel from the given buffer, then further attempts to write to the channel will cause an unspecific runtime exception to be thrown.
Otherwise this method works in the same manner as the AsynchronousByteChannel.write(ByteBuffer,Object,CompletionHandler) method.
Type Parameters:A
- The type of the attachment
Parameters:src
- The buffer from which bytes are to be retrievedtimeout
- The maximum time for the I/O operation to completeunit
- The time unit of the timeout
argumentattachment
- The object to attach to the I/O operation; can be null
handler
- The handler for consuming the result
Throws:[WritePendingException](../../../java/nio/channels/WritePendingException.html "class in java.nio.channels")
- If a write operation is already in progress on this channel[NotYetConnectedException](../../../java/nio/channels/NotYetConnectedException.html "class in java.nio.channels")
- If this channel is not yet connected[ShutdownChannelGroupException](../../../java/nio/channels/ShutdownChannelGroupException.html "class in java.nio.channels")
- If the channel group has terminated
write
public final void write(ByteBuffer src,
A attachment,
CompletionHandler<Integer,? super A> handler)
Writes a sequence of bytes to this channel from the given buffer.
This method initiates an asynchronous write operation to write a sequence of bytes to this channel from the given buffer. The handler
parameter is a completion handler that is invoked when the write operation completes (or fails). The result passed to the completion handler is the number of bytes written.
The write operation may 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 time that the write is attempted. Where_r_ is 0, the write operation completes immediately with a result of0
without initiating an I/O operation.
Suppose that a byte sequence of length n is written, where0 < 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 the write is performed; the index of the last byte written will be_p_ + n - 1. Upon completion the buffer's position will be equal to_p_ + n; its limit will not have changed.
Buffers are not safe for use by multiple concurrent threads so care should be taken to not access the buffer until the operation has completed.
This method may be invoked at any time. Some channel types may not allow more than one write to be outstanding at any given time. If a thread initiates a write operation before a previous write operation has completed then a WritePendingException will be thrown.
Specified by:[write](../../../java/nio/channels/AsynchronousByteChannel.html#write-java.nio.ByteBuffer-A-java.nio.channels.CompletionHandler-)
in interface [AsynchronousByteChannel](../../../java/nio/channels/AsynchronousByteChannel.html "interface in java.nio.channels")
Type Parameters:A
- The type of the attachment
Parameters:src
- The buffer from which bytes are to be retrievedattachment
- The object to attach to the I/O operation; can be null
handler
- The completion handler object
Throws:[WritePendingException](../../../java/nio/channels/WritePendingException.html "class in java.nio.channels")
- If the channel does not allow more than one write to be outstanding and a previous write has not completed[NotYetConnectedException](../../../java/nio/channels/NotYetConnectedException.html "class in java.nio.channels")
- If this channel is not yet connected[ShutdownChannelGroupException](../../../java/nio/channels/ShutdownChannelGroupException.html "class in java.nio.channels")
- If the channel group has terminated
write
public abstract Future<Integer> write(ByteBuffer src)
Writes a sequence of bytes to this channel from the given buffer.
This method initiates an asynchronous write operation to write a sequence of bytes to this channel from the given buffer. The method behaves in exactly the same manner as the write(ByteBuffer,Object,CompletionHandler) method except that instead of specifying a completion handler, this method returns a Future
representing the pending result. The Future
's get method returns the number of bytes written.
Specified by:[write](../../../java/nio/channels/AsynchronousByteChannel.html#write-java.nio.ByteBuffer-)
in interface [AsynchronousByteChannel](../../../java/nio/channels/AsynchronousByteChannel.html "interface in java.nio.channels")
Parameters:src
- The buffer from which bytes are to be retrieved
Returns:
A Future representing the result of the operation
Throws:[WritePendingException](../../../java/nio/channels/WritePendingException.html "class in java.nio.channels")
- If the channel does not allow more than one write to be outstanding and a previous write has not completed[NotYetConnectedException](../../../java/nio/channels/NotYetConnectedException.html "class in java.nio.channels")
- If this channel is not yet connected
write
public abstract void write(ByteBuffer[] srcs,
int offset,
int length,
long timeout,
TimeUnit unit,
A attachment,
CompletionHandler<Long,? super A> handler)
Writes a sequence of bytes to this channel from a subsequence of the given buffers. This operation, sometimes called a gathering write, is often useful when implementing network protocols that group data into segments consisting of one or more fixed-length headers followed by a variable-length body. The handler
parameter is a completion handler that is invoked when the write operation completes (or fails). The result passed to the completion handler is the number of bytes written.
This method initiates a write of up to r bytes to this channel, where r is the total number of bytes remaining in the specified subsequence of the given buffer array, that is,
srcs[offset].remaining()
+ srcs[offset+1].remaining()
+ ... + srcs[offset+length-1].remaining()
at the moment that the write is attempted.
Suppose that a byte sequence of length n is written, where0 < n <= r. Up to the first srcs[offset].remaining() bytes of this sequence are written from buffer srcs[offset], up to the nextsrcs[offset+1].remaining() bytes are written from buffersrcs[offset+1], and so forth, until the entire byte sequence is written. As many bytes as possible are written from each buffer, hence the final position of each updated buffer, except the last updated buffer, is guaranteed to be equal to that buffer's limit. The underlying operating system may impose a limit on the number of buffers that may be used in an I/O operation. Where the number of buffers (with bytes remaining), exceeds this limit, then the I/O operation is performed with the maximum number of buffers allowed by the operating system.
If a timeout is specified and the timeout elapses before the operation completes then it completes with the exception InterruptedByTimeoutException. Where a timeout occurs, and the implementation cannot guarantee that bytes have not been written, or will not be written to the channel from the given buffers, then further attempts to write to the channel will cause an unspecific runtime exception to be thrown.
Type Parameters:A
- The type of the attachment
Parameters:srcs
- The buffers from which bytes are to be retrievedoffset
- The offset within the buffer array of the first buffer from which bytes are to be retrieved; must be non-negative and no larger thansrcs.length
length
- The maximum number of buffers to be accessed; must be non-negative and no larger thansrcs.length - offset
timeout
- The maximum time for the I/O operation to completeunit
- The time unit of thetimeout
argumentattachment
- The object to attach to the I/O operation; can benull
handler
- The handler for consuming the result
Throws:[IndexOutOfBoundsException](../../../java/lang/IndexOutOfBoundsException.html "class in java.lang")
- If the pre-conditions for theoffset
andlength
parameter aren't met[WritePendingException](../../../java/nio/channels/WritePendingException.html "class in java.nio.channels")
- If a write operation is already in progress on this channel[NotYetConnectedException](../../../java/nio/channels/NotYetConnectedException.html "class in java.nio.channels")
- If this channel is not yet connected[ShutdownChannelGroupException](../../../java/nio/channels/ShutdownChannelGroupException.html "class in java.nio.channels")
- If the channel group has terminated
getLocalAddress
public abstract SocketAddress getLocalAddress()
throws IOException
Returns the socket address that this channel's socket is bound to.
Where the channel is bound to an Internet Protocol socket address then the return value from this method is of type InetSocketAddress.
If there is a security manager set, its checkConnect
method is called with the local address and -1
as its arguments to see if the operation is allowed. If the operation is not allowed, a SocketAddress
representing theloopback address and the local port of the channel's socket is returned.
Specified by:[getLocalAddress](../../../java/nio/channels/NetworkChannel.html#getLocalAddress--)
in interface [NetworkChannel](../../../java/nio/channels/NetworkChannel.html "interface in java.nio.channels")
Returns:
The SocketAddress
that the socket is bound to, or theSocketAddress
representing the loopback address if denied by the security manager, or null
if the channel's socket is not bound
Throws:[ClosedChannelException](../../../java/nio/channels/ClosedChannelException.html "class in java.nio.channels")
- If the channel is closed[IOException](../../../java/io/IOException.html "class in java.io")
- If an I/O error occurs