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 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 void
read(SocketChannel channel, ByteBuffer buffer)
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 of 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 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 newInetSocketAddress
instance 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 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
- 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
ByteBuffer
instance. - Throws:
ComException
-
readCompletely
public static ByteBuffer readCompletely(SocketChannel socketChannel, ByteBuffer byteBuffer) throws ComException
This method either read to completely fill the passedByteBuffer
from position to limit or it throws an exception to indicate failure.- Parameters:
socketChannel
-byteBuffer
-- Returns:
- the passed
ByteBuffer
instance. - 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:
ComException
ComExceptionTimeout
-
writeFromBuffer
public static void writeFromBuffer(SocketChannel channel, ByteBuffer buffer, int responseTimeout) throws ComException, ComExceptionTimeout
- Throws:
ComException
ComExceptionTimeout
-
-