Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
public abstract class SocketChannel
extends AbstractSelectableChannel
implements ByteChannel, ScatteringByteChannel, GatheringByteChannel
Constructor Summary | |
|
Method Summary | |
abstract boolean |
|
abstract boolean |
|
abstract boolean |
|
abstract boolean |
|
static SocketChannel |
|
static SocketChannel |
|
abstract int |
|
long |
|
abstract long |
|
abstract Socket |
|
int |
|
abstract int |
|
long |
|
abstract long |
|
Methods inherited from class java.nio.channels.spi.AbstractSelectableChannel | |
blockingLock , configureBlocking , implCloseChannel , implCloseSelectableChannel , implConfigureBlocking , isBlocking , isRegistered , keyFor , provider , register |
Methods inherited from class java.nio.channels.SelectableChannel | |
blockingLock , configureBlocking , isBlocking , isRegistered , keyFor , provider , register , register , validOps |
Methods inherited from class java.nio.channels.spi.AbstractInterruptibleChannel | |
begin , close , end , implCloseChannel , isOpen |
Methods inherited from class java.lang.Object | |
clone , equals , extends Object> getClass , finalize , hashCode , notify , notifyAll , toString , wait , wait , wait |
public abstract boolean connect(SocketAddress remote) throws IOException
Connects the channel's socket to the remote address.
- Returns:
true
if the channel got successfully connected,false
if the channel is in non-blocking mode and connection operation is still in progress.
- Throws:
AlreadyConnectedException
- If this channel is already connected.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 abstract boolean finishConnect() throws IOException
Finishes the process of connecting a socket channel.
- Throws:
IOException
- If an error occursNoConnectionPendingException
- If this channel is not connected and a connection operation has not been initiated.
public abstract boolean isConnected()
Tells whether or not the channel's socket is connected.
public abstract boolean isConnectionPending()
Tells whether or not a connection operation is in progress on this channel.
public static SocketChannel open() throws IOException
Opens a socket channel.
- Returns:
- the new
SocketChannel
object
- Throws:
IOException
- If an error occurs
public static SocketChannel open(SocketAddress remote) throws IOException
Opens a channel and connects it to a remote address.
- Returns:
- the new
SocketChannel
object
- Throws:
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 abstract int read(ByteBuffer dst) throws IOException
Reads data from the channel.
- Specified by:
- read in interface ReadableByteChannel
- Returns:
- the number of bytes read, zero is valid too, -1 if end of stream is reached
- Throws:
IOException
- If an error occursNotYetConnectedException
- If this channel is not yet connected.
public final long read(ByteBuffer[] dsts) throws IOException
Reads data from the channel.
- Specified by:
- read in interface ScatteringByteChannel
- Returns:
- the number of bytes read, zero is valid too, -1 if end of stream is reached
- Throws:
IOException
- If an error occursNotYetConnectedException
- If this channel is not yet connected.
public abstract long read(ByteBuffer[] dsts, int offset, int length) throws IOException
Reads data from the channel.
- Specified by:
- read in interface ScatteringByteChannel
- Returns:
- the number of bytes read, zero is valid too, -1 if end of stream is reached
- Throws:
IOException
- If an error occursNotYetConnectedException
- If this channel is not yet connected.
public final int validOps()
Retrieves the valid operations for this channel.
- Overrides:
- validOps in interface SelectableChannel
- Returns:
- the valid operations
public abstract int write(ByteBuffer src) throws IOException
Writes data to the channel.
- Specified by:
- write in interface WritableByteChannel
- Returns:
- the number of bytes written, zero is valid too
- Throws:
IOException
- If an error occursNotYetConnectedException
- If this channel is not yet connected.
public final long write(ByteBuffer[] dsts) throws IOException
Writes data to the channel.
- Specified by:
- write in interface GatheringByteChannel
- Returns:
- the number of bytes written, zero is valid too
- Throws:
IOException
- If an error occursNotYetConnectedException
- If this channel is not yet connected.
public abstract long write(ByteBuffer[] srcs, int offset, int length) throws IOException
Writes data to the channel.
- Specified by:
- write in interface GatheringByteChannel
- Returns:
- the number of bytes written, zero is valid too
- Throws:
IOException
- If an error occursNotYetConnectedException
- If this channel is not yet connected.