From 31053abd93d69b5fc2d98391db100e4695e29975 Mon Sep 17 00:00:00 2001 From: ForestSpring <1330157839@qq.com> Date: Wed, 28 Jun 2023 20:31:59 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=BA=BF=E7=A8=8B=E5=89=8D?= =?UTF-8?q?=E7=BC=80&=E4=BF=AE=E6=94=B9=E4=BB=A3=E7=A0=81=E6=B3=A8?= =?UTF-8?q?=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/cn/hutool/socket/aio/AioClientTest.java | 2 +- .../java/cn/hutool/socket/nio/NioServerTest.java | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/hutool-socket/src/test/java/cn/hutool/socket/aio/AioClientTest.java b/hutool-socket/src/test/java/cn/hutool/socket/aio/AioClientTest.java index a3fda7606..49b39d8ba 100755 --- a/hutool-socket/src/test/java/cn/hutool/socket/aio/AioClientTest.java +++ b/hutool-socket/src/test/java/cn/hutool/socket/aio/AioClientTest.java @@ -14,7 +14,7 @@ public class AioClientTest { public static void main(String[] args) throws IOException { final AsynchronousChannelGroup GROUP = AsynchronousChannelGroup.withFixedThreadPool(// RuntimeUtil.getProcessorCount(), // 默认线程池大小 - ThreadFactoryBuilder.create().setNamePrefix("Huool-socket-").build()// + ThreadFactoryBuilder.create().setNamePrefix("Hutool-socket-").build()// ); AioClient client = new AioClient(new InetSocketAddress("localhost", 8899), new SimpleIoAction() { diff --git a/hutool-socket/src/test/java/cn/hutool/socket/nio/NioServerTest.java b/hutool-socket/src/test/java/cn/hutool/socket/nio/NioServerTest.java index f1d74b3ea..195f98578 100755 --- a/hutool-socket/src/test/java/cn/hutool/socket/nio/NioServerTest.java +++ b/hutool-socket/src/test/java/cn/hutool/socket/nio/NioServerTest.java @@ -17,16 +17,16 @@ public class NioServerTest { server.setChannelHandler((sc)->{ ByteBuffer readBuffer = ByteBuffer.allocate(1024); try{ - //从channel读数据到缓冲区 + // 从channel读数据到缓冲区 int readBytes = sc.read(readBuffer); if (readBytes > 0) { - //Flips this buffer. The limit is set to the current position and then + // Flips this buffer. The limit is set to the current position and then // the position is set to zero,就是表示要从起始位置开始读取数据 readBuffer.flip(); - //eturns the number of elements between the current position and the limit. + // returns the number of elements between the current position and the limit. // 要读取的字节长度 byte[] bytes = new byte[readBuffer.remaining()]; - //将缓冲区的数据读到bytes数组 + // 将缓冲区的数据读到bytes数组 readBuffer.get(bytes); String body = StrUtil.utf8Str(bytes); Console.log("[{}]: {}", sc.getRemoteAddress(), body); @@ -44,7 +44,7 @@ public class NioServerTest { public static void doWrite(SocketChannel channel, String response) throws IOException { response = "收到消息:" + response; - //将缓冲数据写入渠道,返回给客户端 + // 将缓冲数据写入渠道,返回给客户端 channel.write(BufferUtil.createUtf8(response)); } -} \ No newline at end of file +}