Index (Frames) | Index (No Frames) | Package | Package Tree | Tree
java.nio.channels

Class SocketChannel

java.lang.Object
|
+--java.nio.channels.spi.AbstractInterruptibleChannel
   |
   +--java.nio.channels.SelectableChannel
      |
      +--java.nio.channels.spi.AbstractSelectableChannel
         |
         +--java.nio.channels.SocketChannel

All Implemented Interfaces:

ByteChannel, ScatteringByteChannel, GatheringByteChannel, Channel, InterruptibleChannel


public abstract class SocketChannel

extends AbstractSelectableChannel

implements ByteChannel, ScatteringByteChannel, GatheringByteChannel

Since:Author:

Constructor Summary

SocketChannel(java.nio.channels.spi.SelectorProvider provider)

Initializes this socket.

Method Summary

booleanconnect(java.net.SocketAddress remote)

Connects the channel's socket to the remote address.
booleanfinishConnect()

Finishes the process of connecting a socket channel.
booleanisConnected()

Tells whether or not the channel's socket is connected.
booleanisConnectionPending()

Tells whether or not a connection operation is in progress on this channel.
static java.nio.channels.SocketChannelopen()

Opens a socket channel.
static java.nio.channels.SocketChannelopen(java.net.SocketAddress remote)

Opens a channel and connects it to a remote address.
longread(java.nio.ByteBuffer[] dsts)

Reads data from the channel.
intread(java.nio.ByteBuffer dst)

Reads data from the channel.
longread(java.nio.ByteBuffer[] dsts, int offset, int length)

Reads data from the channel.
java.net.Socketsocket()

Retrieves the channel's socket.
intvalidOps()

Retrieves the valid operations for this channel.
longwrite(java.nio.ByteBuffer[] dsts)

Writes data to the channel.
intwrite(java.nio.ByteBuffer src)

Writes data to the channel.
longwrite(java.nio.ByteBuffer[] srcs, int offset, int length)

Writes data to the channel.

Constructor Details

SocketChannel

protected SocketChannel(java.nio.channels.spi.SelectorProvider provider)

Initializes this socket.

Parameters:


Method Details

connect

public boolean connect(java.net.SocketAddress remote)

Connects the channel's socket to the remote address.

Parameters:

Throws:


finishConnect

public boolean finishConnect()

Finishes the process of connecting a socket channel.

Throws:


isConnected

public boolean isConnected()

Tells whether or not the channel's socket is connected.


isConnectionPending

public boolean isConnectionPending()

Tells whether or not a connection operation is in progress on this channel.


open

public static SocketChannel open()

Opens a socket channel.

Throws:


open

public static SocketChannel open(java.net.SocketAddress remote)

Opens a channel and connects it to a remote address.

Parameters:

Throws:


read

public final long read(java.nio.ByteBuffer[] dsts)

Reads data from the channel.

Parameters:

Throws:


read

public int read(java.nio.ByteBuffer dst)

Reads data from the channel.

Parameters:

Throws:


read

public long read(java.nio.ByteBuffer[] dsts, int offset, int length)

Reads data from the channel.

Parameters:

Throws:


socket

public Socket socket()

Retrieves the channel's socket.


validOps

public final int validOps()

Retrieves the valid operations for this channel.


write

public final long write(java.nio.ByteBuffer[] dsts)

Writes data to the channel.

Parameters:

Throws:


write

public int write(java.nio.ByteBuffer src)

Writes data to the channel.

Parameters:

Throws:


write

public long write(java.nio.ByteBuffer[] srcs, int offset, int length)

Writes data to the channel.

Parameters:

Throws: