Package one.microstream.com
Class XSockets
java.lang.Object
one.microstream.com.XSockets
public final class XSockets extends Object
-
Method Summary
Modifier and Type Method Description static SocketChannel
acceptSocketChannel(ServerSocketChannel serverSocketChannel)
static ByteOrder
byteOrder()
static void
closeChannel(NetworkChannel channel)
static InetAddress
localHostAddress()
Alias forInetAddress.getLocalHost()
.static InetSocketAddress
localHostSocketAddress()
Creates a newInetSocketAddress
instance withlocalHostAddress()
and port 0 (ephemeral port).static InetSocketAddress
localHostSocketAddress(int port)
Creates a newInetSocketAddress
instance withlocalHostAddress()
and the passed port value.static SocketChannel
openChannel(InetSocketAddress address)
static SocketChannel
openChannelLocalhost()
static SocketChannel
openChannelLocalhost(int port)
static ServerSocketChannel
openServerSocketChannel(InetSocketAddress address)
static int
read(SocketChannel channel, ByteBuffer buffer)
static ByteBuffer
read(SocketChannel channel, ByteBuffer buffer, int length)
static ByteBuffer
readCompletely(SocketChannel socketChannel, ByteBuffer byteBuffer)
This method either read to completely fill the passedByteBuffer
from position to limit ,or it throws an exception to indicate failure.static void
readIntoBuffer(SocketChannel channel, ByteBuffer buffer, int responseTimeout)
static ByteBuffer
readIntoBufferKnownLength(SocketChannel channel, ByteBuffer buffer, int responseTimeout, int length)
static void
write(SocketChannel channel, ByteBuffer buffer)
static ByteBuffer
writeCompletely(SocketChannel socketChannel, ByteBuffer byteBuffer)
This method either writes all the passedByteBuffer
's bytes from position to limit ,or it throws an exception to indicate failure.static void
writeFromBuffer(SocketChannel channel, ByteBuffer buffer, int responseTimeout)
-
Method Details
-
byteOrder
-
openServerSocketChannel
public static final ServerSocketChannel openServerSocketChannel(InetSocketAddress address) throws ComException- Throws:
ComException
-
acceptSocketChannel
public static final SocketChannel acceptSocketChannel(ServerSocketChannel serverSocketChannel) throws ComException- Throws:
ComException
-
openChannel
- Throws:
ComException
-
localHostAddress
Alias forInetAddress.getLocalHost()
.- Returns:
- the localhost
InetAddress
. - Throws:
ComException
- ifInetAddress.getLocalHost()
throws anUnknownHostException
-
localHostSocketAddress
Creates a newInetSocketAddress
instance withlocalHostAddress()
and port 0 (ephemeral port).- Returns:
- a localhost
InetSocketAddress
. - Throws:
ComException
- if a communication error occurs- See Also:
InetSocketAddress(InetAddress, int)
-
localHostSocketAddress
Creates a newInetSocketAddress
instance withlocalHostAddress()
and the passed port value.- Parameters:
port
- the port to be used.- Returns:
- a localhost
InetSocketAddress
with the passed port value. - Throws:
ComException
- if a communication error occurs- See Also:
InetSocketAddress(InetAddress, int)
-
openChannelLocalhost
- Throws:
ComException
-
openChannelLocalhost
- Throws:
ComException
-
closeChannel
- Throws:
ComException
-
writeCompletely
public static ByteBuffer writeCompletely(SocketChannel socketChannel, ByteBuffer byteBuffer) throws ComExceptionThis method either writes all the passedByteBuffer
's bytes from position to limit ,or it throws an exception to indicate failure.- Parameters:
socketChannel
- the target channelbyteBuffer
- the source buffer- Returns:
- the passed
ByteBuffer
instance. - Throws:
ComException
- if a communication error occurs
-
readCompletely
public static ByteBuffer readCompletely(SocketChannel socketChannel, ByteBuffer byteBuffer) throws ComExceptionThis method either read to completely fill the passedByteBuffer
from position to limit ,or it throws an exception to indicate failure.- Parameters:
socketChannel
- the source channelbyteBuffer
- the target buffer- Returns:
- the passed
ByteBuffer
instance. - Throws:
ComException
- if a communication error occurs
-
readIntoBufferKnownLength
public static final ByteBuffer readIntoBufferKnownLength(SocketChannel channel, ByteBuffer buffer, int responseTimeout, int length) throws ComException- Throws:
ComException
-
read
- Throws:
ComException
-
read
-
write
- Throws:
ComException
-
readIntoBuffer
public static void readIntoBuffer(SocketChannel channel, ByteBuffer buffer, int responseTimeout) throws ComException, ComExceptionTimeout- Throws:
ComException
ComExceptionTimeout
-
writeFromBuffer
public static void writeFromBuffer(SocketChannel channel, ByteBuffer buffer, int responseTimeout) throws ComException, ComExceptionTimeout- Throws:
ComException
ComExceptionTimeout
-