第117页
LionHeart (我是最棒的!~)
- 页码:第117页
SocketChannel clientChannel = SocketChannel.open(); clientChannel.configureBlocking(false);//如果加上这句会导致连接不上 if (!clientChannel.connect(isAddress)) { while(!clientChannel.finishConnect()) { System.out.print("."); } }书中的这段代码会导致connect失败,跟踪下去到nio包下的Net.connect就是native方法了,该方法总会返回-2. 解决方式是在client这边不要configureBlocking(false); 或者使用SocketChannel.open(isAddress);这种方式
45人阅读
说明 · · · · · ·
表示其中内容是对原文的摘抄