私はNIOおよびNettyサーバークライアントフレームワークの初心者です。NIOClientNew.javaでデータを暗号化し(クラス NIOClientNew.java に示されているように「Hello!」)、それをNettyサーバーに送信し、Nettyハンドラークラスでデータを復号化することに興味があります.
NIO と Netty でのデータの暗号化と復号化のために何をすべきか教えてくれる人はいますか?
'import java.io.IOException;
import java.net.InetSocketAddress;
import java.nio.ByteBuffer;
import java.nio.channels.SocketChannel;
public class NIOClientNew {
public static final String HELLO_REQUEST = "Hello!";
public static void main(String arg[]) {
SocketChannel sc = null;
try {
sc = SocketChannel.open();
sc.configureBlocking(false);
sc.connect(new InetSocketAddress(6565));
System.out.println("Sending a request to HelloServer");
while (!sc.finishConnect()) {
}
ByteBuffer buffer = ByteBuffer.allocate(65535);
buffer.putInt(HELLO_REQUEST.length());
buffer.put(HELLO_REQUEST.getBytes());
buffer.flip();
try {
sc.write(buffer);
} catch (IOException ex) {
System.out.println(ex.toString());
}
} catch (Exception e) {
System.out.println(e.toString());
} finally {
if (sc != null) {
try {
sc.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
}
'