java.lang.Object | +--java.nio.channels.spi.AbstractInterruptibleChannel | +--java.nio.channels.SelectableChannel | +--java.nio.channels.spi.AbstractSelectableChannel | +--java.nio.channels.SocketChannelAll Implemented Interfaces:
SocketChannel(java.nio.channels.spi.SelectorProvider provider) Initializes this socket. |
boolean | connect(java.net.SocketAddress remote) Connects the channel's socket to the remote address. |
boolean | finishConnect() Finishes the process of connecting a socket channel. |
boolean | isConnected() Tells whether or not the channel's socket is connected. |
boolean | isConnectionPending() Tells whether or not a connection operation is in progress on this channel. |
static java.nio.channels.SocketChannel | open() Opens a socket channel. |
static java.nio.channels.SocketChannel | open(java.net.SocketAddress remote) Opens a channel and connects it to a remote address. |
long | read(java.nio.ByteBuffer[] dsts) Reads data from the channel. |
int | read(java.nio.ByteBuffer dst) Reads data from the channel. |
long | read(java.nio.ByteBuffer[] dsts, int offset, int length) Reads data from the channel. |
java.net.Socket | socket() Retrieves the channel's socket. |
int | validOps() Retrieves the valid operations for this channel. |
long | write(java.nio.ByteBuffer[] dsts) Writes data to the channel. |
int | write(java.nio.ByteBuffer src) Writes data to the channel. |
long | write(java.nio.ByteBuffer[] srcs, int offset, int length) Writes data to the channel. |
protected SocketChannel(java.nio.channels.spi.SelectorProvider provider)
provider
- public boolean connect(java.net.SocketAddress remote)
remote
- AlreadyConnectedException
- If this channel is already connected.AsynchronousCloseException
- If this channel is already connected.ClosedByInterruptException
- If another thread interrupts the
current thread while the connect operation is in progress, thereby closing
the channel and setting the current thread's interrupt status.ClosedChannelException
- If this channel is closed.ConnectionPendingException
- If a non-blocking connection
operation is already in progress on this channel.IOException
- If an error occursSecurityException
- If a security manager has been installed and
it does not permit access to the given remote endpoint.UnresolvedAddressException
- If the given remote address is not
fully resolved.UnsupportedAddressTypeException
- If the type of the given remote
address is not supported.public boolean finishConnect()
AsynchronousCloseException
- If this channel is already connected.ClosedByInterruptException
- If another thread interrupts the
current thread while the connect operation is in progress, thereby closing
the channel and setting the current thread's interrupt status.ClosedChannelException
- If this channel is closed.IOException
- If an error occursNoConnectionPendingException
- If this channel is not connected
and a connection operation has not been initiated.public boolean isConnected()
public boolean isConnectionPending()
public static SocketChannel open()
IOException
- If an error occurspublic static SocketChannel open(java.net.SocketAddress remote)
remote
- AsynchronousCloseException
- If this channel is already connected.ClosedByInterruptException
- If another thread interrupts the
current thread while the connect operation is in progress, thereby closing
the channel and setting the current thread's interrupt status.IOException
- If an error occursSecurityException
- If a security manager has been installed and
it does not permit access to the given remote endpoint.UnresolvedAddressException
- If the given remote address is not
fully resolved.UnsupportedAddressTypeException
- If the type of the given remote
address is not supported.public final long read(java.nio.ByteBuffer[] dsts)
dsts
- IOException
- If an error occursNotYetConnectedException
- If this channel is not yet connected.public int read(java.nio.ByteBuffer dst)
dst
- IOException
- If an error occursNotYetConnectedException
- If this channel is not yet connected.public long read(java.nio.ByteBuffer[] dsts, int offset, int length)
dsts
- offset
- length
- IOException
- If an error occursNotYetConnectedException
- If this channel is not yet connected.public Socket socket()
public final int validOps()
public final long write(java.nio.ByteBuffer[] dsts)
dsts
- IOException
- If an error occursNotYetConnectedException
- If this channel is not yet connected.public int write(java.nio.ByteBuffer src)
src
- IOException
- If an error occursNotYetConnectedException
- If this channel is not yet connected.public long write(java.nio.ByteBuffer[] srcs, int offset, int length)
srcs
- offset
- length
- IOException
- If an error occursNotYetConnectedException
- If this channel is not yet connected.