Java void sendUrgentData() 抛出 SocketException

发布于 2024-11-03 17:24:54 字数 390 浏览 5 评论 0原文

我正在尝试使用 sendUrgentData() void 来确定连接是否仍然有效。通过此 void 发送的数据在服务器端将被忽略,但当连接丢失时,sendUrgentData 在客户端会抛出 SocketException。

这就是应该如何进行。 然而,在多次调用 sendUrgentData 后,当连接仍然完全有效时,它似乎会断开连接并抛出 SocketException:

java.net.SocketException: Connection reset by peer: send

我用嗅探器检查了网络流量,发现重置数据包从未发送。 我应该如何解决这个问题?我试图避免以正常方式发送此数据,以避免损坏流中当前的数据。

I am trying to use the sendUrgentData() void to determine if a connection is still alive. The data send through this void will be ignored on the server side, but when a connection is lost, sendUrgentData throws a SocketException on the client side.

This is how is should go.
However, after calling sendUrgentData several times it seems to disconnect and throw the SocketException when the connection is still perfectly alive:

java.net.SocketException: Connection reset by peer: send

I checked the network traffic with a sniffer and found that the reset packet was never send.
How should I solve this? I'm trying to avoid sending this data the normal way to avoid corrupting the data currently in the stream.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

撩动你心 2024-11-10 17:24:54

发送的数据不会被忽略,如果是用 Java 编写的,它将由服务器内联读取。所以你可能会导致协议错误。对等方重置连接意味着您已写入已被对等方关闭的连接......可能是为了响应协议错误。

The data sent won't be ignored, it will be read inline by the server, if it's written in Java. So you are probably causing a protocol error. Connection reset by peer means you have written to a connection that has already been closed by the peer ... probably in response to the protocol error.

幸福还没到 2024-11-10 17:24:54

如果底层实现不支持发送紧急数据,Socket#sendUrgentData()将抛出SocketException。根据记忆,Java 1.6 上的套接字异常的消息描述类似于“不支持紧急数据”。

  • 您在什么平台上运行(Windows、Linux 等)?

  • 您使用的 Java 版本是什么?

Socket#sendUrgentData() will throw a SocketException if the underlying implementation does not support sending of urgent data. From memory, the socket exception's message description on Java 1.6 is something like 'urgent data is not supported'.

  • What platform are you running on (Windows, Linux, etc) ?

  • What version of Java are you using ?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文