Package one.microstream.com
Class XSockets
- java.lang.Object
-
- one.microstream.com.XSockets
-
public final class XSockets extends Object
-
-
Constructor Summary
Constructors Constructor Description XSockets()
-
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 Detail
-
byteOrder
public static ByteOrder 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
public static SocketChannel openChannel(InetSocketAddress address) throws ComException
- Throws:
ComException
-
localHostAddress
public static InetAddress localHostAddress() throws ComException
Alias forInetAddress.getLocalHost().- Returns:
- the localhost
InetAddress. - Throws:
ComException- ifInetAddress.getLocalHost()throws anUnknownHostException
-
localHostSocketAddress
public static InetSocketAddress localHostSocketAddress() throws ComException
Creates a newInetSocketAddressinstance withlocalHostAddress()and port 0 (ephemeral port).- Returns:
- a localhost
InetSocketAddress. - Throws:
ComException- See Also:
InetSocketAddress(InetAddress,int)
-
localHostSocketAddress
public static InetSocketAddress localHostSocketAddress(int port) throws ComException
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
public static SocketChannel openChannelLocalhost() throws ComException
- Throws:
ComException
-
openChannelLocalhost
public static SocketChannel openChannelLocalhost(int port) throws ComException
- Throws:
ComException
-
closeChannel
public static final void closeChannel(NetworkChannel channel) throws ComException
- Throws:
ComException
-
writeCompletely
public static ByteBuffer writeCompletely(SocketChannel socketChannel, ByteBuffer byteBuffer) throws ComException
This 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 ComException
This 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
public static void read(SocketChannel channel, ByteBuffer buffer) throws ComException
- Throws:
ComException
-
write
public static void write(SocketChannel channel, ByteBuffer buffer) throws ComException
- 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
-
-