AddressUtilpublic class AddressUtil extends Object
Methods Summary |
---|
public static int | getChannelAddress(java.nio.channels.Channel channel)Gets the address of native resource held by the given channel, if has
any.
For network related channel, including SocketChannel, ServerSocketChannel
and DatagramChannel, this method returns a int of Socket handler in Linux
while returns a SOCKET (UINT_PTR) in windows.
For FileChannel, this method returns the native file descriptor.
For other channels, this method return 0, which means unsupported
operation.
if(channel instanceof FileDescriptorHandler){
return getFDAddress(((FileDescriptorHandler) channel).getFD());
}else if(channel instanceof FileChannelImpl){
return ((FileChannelImpl) channel).getHandle();
}
return 0;
| public static int | getDirectBufferAddress(java.nio.Buffer buf)Gets the start address of a direct buffer.
This method corresponds to the JNI function:
void* GetDirectBufferAddress(JNIEnv* env, jobject buf);
if (!(buf instanceof DirectBuffer)) {
return 0;
}
return ((DirectBuffer) buf).getEffectiveAddress().toInt();
| private static native int | getFDAddress(java.io.FileDescriptor fd)
|
|