开发者

How can I verify that a TCP packet has received an ACK in JAVA?

开发者 https://www.devze.com 2023-03-16 11:56 出处:网络
After sending s开发者_Go百科ome tcp data by any method (mine is below) DataOutputStream outToServer = new DataOutputStream(clientSocket.getOutputStream());

After sending s开发者_Go百科ome tcp data by any method (mine is below)

DataOutputStream outToServer = new DataOutputStream(clientSocket.getOutputStream());
outToServer.writeBytes(string);

How can I verify in JAVA that TCP data is sent successfully? OR is there any way of reading the ACK received (from tcpserver) ?


You cannot. Operating systems typically does not expose this to applications.

If you need to know whether data has made it to the other end, you need to implement acks at your application protocol, not at the transport level that TCP concerns itself with.


I always use Wireshark to debug TCP apps. It is a TCP tracing tool that shows you the individual packets with their acks, retransmits etc.

It is not in code, but it does allow you to double check the behavior of your app.

Check wireshark.

0

精彩评论

暂无评论...
验证码 换一张
取 消