try {
TypeUDT type = TypeUDT.DATAGRAM;
SocketUDT socket = new SocketUDT(type);
ByteBuffer byteBuffer = ByteBuffer.allocateDirect(1024);
log.info("byteBuffer.isDirect={}", byteBuffer.isDirect());
socket.testDirectByteBufferAccess0(byteBuffer);
for (int k = 0; k < 3; k++) {
byte byteValue = byteBuffer.get(k);
log.info("k={} byteBuffer[k]={}", k, (char) byteValue);
}
//
IntBuffer intBuffer = ByteBuffer.allocateDirect(1024 * 4).order(
ByteOrder.nativeOrder()).asIntBuffer();
log.info("intBuffer.isDirect={}", intBuffer.isDirect());
for (int k = 0; k < 3; k++) {
intBuffer.put(k, 0);
}
socket.testDirectIntBufferAccess0(intBuffer);
for (int k = 0; k < 3; k++) {
int intValue = intBuffer.get(k);
log.info("k={} intBuffer[k]={}", k, (char) intValue);
}