练习AIO模型实现,启动client端报错

来源:9-8 AIO客户端实现

慕粉2344238606

2021-01-15

老师,您好。我在练习AIO模型时,启动客户端后,
// 创建channel
clientChannel = AsynchronousSocketChannel.open();
Future future = clientChannel.connect(new InetSocketAddress(host, port));
future.get();
创建了channel,在调用 future.get()出现如下报错:
java.util.concurrent.ExecutionException: java.io.IOException: Result too large
at sun.nio.ch.PendingFuture.get(PendingFuture.java:185)
at Demo06.client.ChatClient06.start(ChatClient06.java:52)
at Demo06.client.ChatClient06.main(ChatClient06.java:96)
Caused by: java.io.IOException: Result too large
at sun.nio.ch.WindowsAsynchronousSocketChannelImpl.connect0(Native Method)
at sun.nio.ch.WindowsAsynchronousSocketChannelImpl.access200(WindowsAsynchronousSocketChannelImpl.java:43)atsun.nio.ch.WindowsAsynchronousSocketChannelImpl200(WindowsAsynchronousSocketChannelImpl.java:43) at sun.nio.ch.WindowsAsynchronousSocketChannelImpl200(WindowsAsynchronousSocketChannelImpl.java:43)atsun.nio.ch.WindowsAsynchronousSocketChannelImplConnectTask.run(WindowsAsynchronousSocketChannelImpl.java:235)
at sun.nio.ch.WindowsAsynchronousSocketChannelImpl.implConnect(WindowsAsynchronousSocketChannelImpl.java:382)
at sun.nio.ch.AsynchronousSocketChannelImpl.connect(AsynchronousSocketChannelImpl.java:199)
at Demo06.client.ChatClient06.start(ChatClient06.java:51)
… 1 more
第一次是跟着老师的视频讲解一步步实现的,启动时报错了,以为是自已有代码漏掉了。后来把代码库里老师的源码下载了下来,启动客户端同样还是报错。找了好久,找不到问题所在,希望老师能帮我解惑。

写回答

1回答

Stannum

2021-01-18

同学你好~我目前还没有重现你说的这个错误。可否请你把操作的步骤再详细介绍一下?你有更改课程代码吗?如果细节比较多的话,建议你直接在qq上小窗ping我~

0
0

系统学习Java网络编程 深度理解BIO/NIO/AIO

对比式学习助你真正理解BIO/NIO/AIO三大网络编程模型。

880 学习 · 148 问题

查看课程