简体   繁体   English

在 Java 中获取 DatagramSocket 接收缓冲区的剩余可用空间长度

[英]Getting the remaining free space length on DatagramSocket's receive buffer in Java

So we are developing a transport protocol based on UDP.所以我们正在开发基于UDP的传输协议。 One characteristic of the expected output is that it should have reliable data transfer.预期输出的特征之一是它应该具有可靠的数据传输。 A requirement of which is that the protocol should have flow control.其中一个要求是协议应该具有流量控制。 Because of this, the remaining free space on the receiving buffer of DatagramSocket calls the need to be monitored.正因为如此,DatagramSocket 调用的接收缓冲区上剩余的空闲空间需要被监控。 However, I do not find such method in the javadoc of the said class.但是,我在该类的 javadoc 中没有找到这样的方法。 Is there any way to determine the free space left in the receiving buffer?有没有办法确定接收缓冲区中剩余的可用空间?

You are correct.你是对的。 There is no such method in the Java API. Java API 中没有这样的方法。 There is a socket option for it at the C level in some but not all operating systems.在某些但不是所有操作系统中,它在 C 级别有一个套接字选项。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM