向关闭的连接写入响应时也不例外 [英] No exception when writing response to closed connection

查看:150
本文介绍了向关闭的连接写入响应时也不例外的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在JBoss 5.1上有一个简单的servlet. 编写响应时,如果连接关闭,也不例外. 通过读取超时从外部关闭了连接.

I have simple servlet on JBoss 5.1. When writing response a have no exception if connection closed. Connection closed by read timeout, from outside.

JBoss接收FIN,ACK,并用ACK应答,几秒钟后发送我的响应(PSH,ACK)并接收RST.

JBoss receives FIN, ACK, answers with ACK and after several seconds sends my response (PSH,ACK) and receives RST.

如何在servlet中确定连接已关闭和/或响应未成功写完?

How to determine in servlet, that connection is closed and/or response is not writtеn successfully?

推荐答案

如果您写入了足够的数据,以便在RST到达后仍在写入,则会收到IOException:对等连接重置". TCP缓冲和异步写入意味着少量写入可能不会发生这种情况.

If you write enough data so that you are still writing after the RST arrives you will get an IOException: 'connection reset by peer'. TCP buffering and asynchronous writing means that this may not happen for a small write.

这篇关于向关闭的连接写入响应时也不例外的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆