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 SocketChannelacceptSocketChannel(ServerSocketChannel serverSocketChannel)static ByteOrderbyteOrder()static voidcloseChannel(NetworkChannel channel)static InetAddresslocalHostAddress()Alias forInetAddress.getLocalHost().static InetSocketAddresslocalHostSocketAddress()Creates a newInetSocketAddressinstance withlocalHostAddress()and port 0 (ephemeral port).static InetSocketAddresslocalHostSocketAddress(int port)Creates a newInetSocketAddressinstance withlocalHostAddress()and the passed port value.static SocketChannelopenChannel(InetSocketAddress address)static SocketChannelopenChannelLocalhost()static SocketChannelopenChannelLocalhost(int port)static ServerSocketChannelopenServerSocketChannel(InetSocketAddress address)static voidread(SocketChannel channel, ByteBuffer buffer)static ByteBufferreadCompletely(SocketChannel socketChannel, ByteBuffer byteBuffer)This method either read to completely fill the passedByteBufferfrom position to limit or it throws an exception to indicate failure.static voidreadIntoBuffer(SocketChannel channel, ByteBuffer buffer, int responseTimeout)static ByteBufferreadIntoBufferKnownLength(SocketChannel channel, ByteBuffer buffer, int responseTimeout, int length)static voidwrite(SocketChannel channel, ByteBuffer buffer)static ByteBufferwriteCompletely(SocketChannel socketChannel, ByteBuffer byteBuffer)This method either writes all of the passedByteBuffer's bytes from position to limit or it throws an exception to indicate failure.static voidwriteFromBuffer(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 newInetSocketAddressinstance withlocalHostAddress()and port 0 (ephemeral port).- Returns:
- a localhost
InetSocketAddress. - Throws:
ComException- See Also:
InetSocketAddress(InetAddress, int)
-
localHostSocketAddress
Creates a newInetSocketAddressinstance withlocalHostAddress()and the passed port value.- Parameters:
port- the port to be used.- Returns:
- a localhost
InetSocketAddresswith the passed port value. - Throws:
ComException- 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 of the passedByteBuffer's bytes from position to limit or it throws an exception to indicate failure.- Parameters:
socketChannel-byteBuffer-- Returns:
- the passed
ByteBufferinstance. - Throws:
ComException
-
readCompletely
public static ByteBuffer readCompletely(SocketChannel socketChannel, ByteBuffer byteBuffer) throws ComExceptionThis method either read to completely fill the passedByteBufferfrom position to limit or it throws an exception to indicate failure.- Parameters:
socketChannel-byteBuffer-- Returns:
- the passed
ByteBufferinstance. - Throws:
ComException
-
readIntoBufferKnownLength
public static final ByteBuffer readIntoBufferKnownLength(SocketChannel channel, ByteBuffer buffer, int responseTimeout, int length) throws ComException- Throws:
ComException
-
read
- Throws:
ComException
-
write
- Throws:
ComException
-
readIntoBuffer
public static void readIntoBuffer(SocketChannel channel, ByteBuffer buffer, int responseTimeout) throws ComException, ComExceptionTimeout- Throws:
ComExceptionComExceptionTimeout
-
writeFromBuffer
public static void writeFromBuffer(SocketChannel channel, ByteBuffer buffer, int responseTimeout) throws ComException, ComExceptionTimeout- Throws:
ComExceptionComExceptionTimeout
-