Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/308.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sockets/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java非阻塞IO:在调用channel.write()之前,是否可以检查可以写入多少?_Java_Sockets_Real Time_Nio_Nonblocking - Fatal编程技术网

Java非阻塞IO:在调用channel.write()之前,是否可以检查可以写入多少?

Java非阻塞IO:在调用channel.write()之前,是否可以检查可以写入多少?,java,sockets,real-time,nio,nonblocking,Java,Sockets,Real Time,Nio,Nonblocking,我知道channel.write(Exputffer)可能无法写入Exputffer的所有内容,因为底层套接字缓冲区已满。然后您必须注册OP_WRITE并等待选择器回调。但是,我不希望写入部分消息,我希望等待channel.write操作能够写入完整消息。这是可能的,还是我必须写信才能知道我能写多少 当然是谈论a。别担心。TCP中没有“消息”这样的东西。TCP可能会以它喜欢的任何方式中断您的写操作,并且接收方可能会在一次读取或N次读取之间接收到它 你在说什么样的频道?频道本身只有isOpen和

我知道channel.write(Exputffer)可能无法写入Exputffer的所有内容,因为底层套接字缓冲区已满。然后您必须注册OP_WRITE并等待选择器回调。但是,我不希望写入部分消息,我希望等待channel.write操作能够写入完整消息。这是可能的,还是我必须写信才能知道我能写多少



当然是谈论a。

别担心。TCP中没有“消息”这样的东西。TCP可能会以它喜欢的任何方式中断您的写操作,并且接收方可能会在一次读取或N次读取之间接收到它

你在说什么样的频道?频道本身只有
isOpen
close
方法:@chrisapotek-由于Java中使用NIO来引用Java.NIO中的“新IO”包,因此根据您在我的回答中的注释,将标题更改为“非阻塞IO”,我现在将其删除。