|
barchart-udt-core 2.3.0-SNAPSHOT / 2013-05-13T01:37:38.485-0500 |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.nio.channels.spi.AbstractInterruptibleChannel
java.nio.channels.SelectableChannel
java.nio.channels.spi.AbstractSelectableChannel
java.nio.channels.SocketChannel
com.barchart.udt.nio.SocketChannelUDT
public class SocketChannelUDT
SocketChannel-like wrapper for SocketUDT, can be either
stream or message oriented, depending on TypeUDT
The UDT socket that this SocketChannel wraps will be switched to blocking mode since this is the default for all SocketChannels on construction. If you require non-blocking functionality, you will need to call configureBlocking on the constructed SocketChannel class.
you must use SelectorProviderUDT.openSocketChannel() to obtain
instance of this class; do not use JDK
SocketChannel.open();
example:
SelectorProvider provider = SelectorProviderUDT.DATAGRAM;
SocketChannel clientChannel = provider.openSocketChannel();
clientChannel.configureBlocking(true);
Socket clientSocket = clientChannel.socket();
InetSocketAddress clientAddress = new InetSocketAddress("localhost", 10000);
clientSocket.bind(clientAddress);
assert clientSocket.isBound();
InetSocketAddress serverAddress = new InetSocketAddress("localhost", 12345);
clientChannel.connect(serverAddress);
assert clientSocket.isConnected();
| Field Summary | |
|---|---|
protected Object |
connectLock
|
protected boolean |
isBlockingMode
local volatile variable, which mirrors super.blocking, to avoid the cost of synchronized call inside isBlocking() |
protected boolean |
isConnectFinished
|
protected boolean |
isConnectionPending
|
protected static org.slf4j.Logger |
log
|
protected NioSocketUDT |
socketAdapter
|
protected SocketUDT |
socketUDT
|
| Constructor Summary | |
|---|---|
protected |
SocketChannelUDT(SelectorProviderUDT provider,
SocketUDT socketUDT)
|
protected |
SocketChannelUDT(SelectorProviderUDT provider,
SocketUDT socketUDT,
boolean isConnected)
|
| Method Summary | |
|---|---|
SocketChannelUDT |
bind(SocketAddress localAddress)
java 7 |
boolean |
connect(SocketAddress remote)
|
boolean |
finishConnect()
|
protected void |
implCloseSelectableChannel()
|
protected void |
implConfigureBlocking(boolean block)
|
boolean |
isConnected()
|
boolean |
isConnectFinished()
Was connection request connect(java.net.SocketAddress) acknowledged by
finishConnect()? |
boolean |
isConnectionPending()
|
KindUDT |
kindUDT()
The kind of UDT channel. |
SelectorProviderUDT |
providerUDT()
UDT specific provider which produced this channel. |
int |
read(ByteBuffer buffer)
See SocketChannel.read(ByteBuffer) contract;
note: this method does not return (-1) as EOS (end of stream flag) |
long |
read(ByteBuffer[] dsts,
int offset,
int length)
|
NioSocketUDT |
socket()
|
SocketUDT |
socketUDT()
Underlying UDT socket. |
String |
toString()
|
TypeUDT |
typeUDT()
The type of UDT socket. |
int |
write(ByteBuffer buffer)
See SocketChannel.write(ByteBuffer) contract; |
long |
write(ByteBuffer[] bufferArray,
int offset,
int length)
|
| Methods inherited from class java.nio.channels.SocketChannel |
|---|
open, open, read, validOps, write |
| Methods inherited from class java.nio.channels.spi.AbstractSelectableChannel |
|---|
blockingLock, configureBlocking, implCloseChannel, isBlocking, isRegistered, keyFor, provider, register |
| Methods inherited from class java.nio.channels.SelectableChannel |
|---|
register |
| Methods inherited from class java.nio.channels.spi.AbstractInterruptibleChannel |
|---|
begin, close, end, isOpen |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface com.barchart.udt.nio.ChannelUDT |
|---|
validOps |
| Methods inherited from interface java.nio.channels.Channel |
|---|
close, isOpen |
| Field Detail |
|---|
protected static final org.slf4j.Logger log
protected final Object connectLock
protected volatile boolean isBlockingMode
protected volatile boolean isConnectFinished
protected volatile boolean isConnectionPending
@ThreadSafe(value="this") protected NioSocketUDT socketAdapter
protected final SocketUDT socketUDT
| Constructor Detail |
|---|
protected SocketChannelUDT(SelectorProviderUDT provider,
SocketUDT socketUDT)
throws ExceptionUDT
ExceptionUDT
protected SocketChannelUDT(SelectorProviderUDT provider,
SocketUDT socketUDT,
boolean isConnected)
throws ExceptionUDT
ExceptionUDT| Method Detail |
|---|
public boolean connect(SocketAddress remote)
throws IOException
connect in class SocketChannelIOException
public boolean finishConnect()
throws IOException
finishConnect in class SocketChannelIOException
protected void implCloseSelectableChannel()
throws IOException
implCloseSelectableChannel in class AbstractSelectableChannelIOException
protected void implConfigureBlocking(boolean block)
throws IOException
implConfigureBlocking in class AbstractSelectableChannelIOExceptionpublic boolean isConnected()
isConnected in class SocketChannelpublic boolean isConnectFinished()
ChannelUDTconnect(java.net.SocketAddress) acknowledged by
finishConnect()?
isConnectFinished in interface ChannelUDTpublic boolean isConnectionPending()
isConnectionPending in class SocketChannelpublic KindUDT kindUDT()
ChannelUDT
kindUDT in interface ChannelUDTpublic SelectorProviderUDT providerUDT()
ChannelUDT
providerUDT in interface ChannelUDT
public int read(ByteBuffer buffer)
throws IOException
SocketChannel.read(ByteBuffer) contract;
note: this method does not return (-1) as EOS (end of stream flag)
read in interface ReadableByteChannelread in class SocketChannel<0 should not happen=0 blocking mode: timeout occurred on receive=0 non-blocking mode: nothing is received by the
underlying UDT socket>0 actual bytes received countIOExceptionSocketUDT.receive(ByteBuffer),
SocketUDT.receive(byte[], int, int)
public long read(ByteBuffer[] dsts,
int offset,
int length)
throws IOException
read in interface ScatteringByteChannelread in class SocketChannelIOExceptionpublic NioSocketUDT socket()
socket in class SocketChannelpublic SocketUDT socketUDT()
ChannelUDT
socketUDT in interface ChannelUDTpublic String toString()
toString in class Object
public int write(ByteBuffer buffer)
throws IOException
SocketChannel.write(ByteBuffer) contract;
write in interface WritableByteChannelwrite in class SocketChannel<0 should not happen=0 blocking mode: timeout occurred on send=0 non-blocking mode: buffer is full in the
underlying UDT socket; nothing is sent>0 actual bytes sent countIOExceptionSocketUDT.send(ByteBuffer),
SocketUDT.send(byte[], int, int)
public long write(ByteBuffer[] bufferArray,
int offset,
int length)
throws IOException
write in interface GatheringByteChannelwrite in class SocketChannelIOExceptionpublic TypeUDT typeUDT()
ChannelUDT
typeUDT in interface ChannelUDT
public SocketChannelUDT bind(SocketAddress localAddress)
throws IOException
IOException
|
barchart-udt-core 2.3.0-SNAPSHOT / 2013-05-13T01:37:38.485-0500 |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||