本文介绍了正确关闭tcp连接抛出java的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用 ESME.com" rel="nofollow noreferrer">logica smpp lib,但有一个严重的问题 -当 SMSC 发送给 ESME [FIN, ACK] 时,ESME 没有正确回答.
I am writing ESME using logica smpp lib, but have a serious problem -when SMSC send to ESME [FIN, ACK], ESME do not answer correct.
这里是 TCP 转储:
Here TCP dump:
2751.016216 ESME -> SMSC SMPP SMPP Submit_sm
2751.019818 SMSC -> ESME SMPP SMPP Submit_sm - resp: "Throttling error (ESME exceeded allowed message limits)"
2751.136172 ESME -> SMSC TCP 42265 > 5001 [ACK] Seq=1651885221 Ack=3959508692 Win=123 Len=0
2774.588453 SMSC -> ESME TCP 5001 > 42265 [FIN, ACK] Seq=3959508692 Ack=1651885221 Win=32768 Len=0
2774.741502 ESME -> SMSC TCP 42265 > 5001 [ACK] Seq=1651885221 Ack=3959508693 Win=123 Len=0
2821.032427 ESME -> SMSC SMPP SMPP Submit_sm
2821.033502 SMSC -> ESME TCP 5001 > 42265 [RST] Seq=3959508693 Ack=0 Win=32768 Len=22
如何解决这个问题?可以处理这个数据包吗?
How to solve this? Is it possible to handle this packet?
推荐答案
在 TCPIPConnection
类中,方法 - public ByteBuffer receive()
你应该这样做:
In class TCPIPConnection
, method - public ByteBuffer receive()
you should do something like this:
bytesRead = inputStream.read(receiveBuffer, 0, bytesToRead);
if (bytesRead == -1){
//close connection here
}
这篇关于正确关闭tcp连接抛出java的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!