0

I am wondering if it is possible to figure out the last byte that a server has sent to a client using TCP connection. To put it in details, I have a client and a server, both in C++. They are communicating using XMLRPC and the connection is TCP. The client can send a big request to the server and it might take some time for the server to reply, due to some calculations. In any part of the connection, if it gets disconnected, the entire process should be done from the scratch, which causes the server vulnerable to DoS attack.

My question is if I can figure out where the connection was disconnected so that after reestablishing the connection (for the same client using some Identifications), the server can send the remaining bytes from the previous request instead of processing request again.

brenjt
  • 15,997
  • 13
  • 77
  • 118
Mohammad Khodaei
  • 501
  • 1
  • 4
  • 15

1 Answers1

2

You should code that support into your protocol. For example, break responses into 4096 byte chunks; then the client can reconnect and say: "I received the first 19 blocks, continue with block 20 please!"

Nik Bougalis
  • 10,495
  • 1
  • 21
  • 37
  • TCP by itself does not keep track of the bytes it is sending and receiving? – Mohammad Khodaei Feb 28 '13 at 17:53
  • 2
    Yes and no. But that's not important. Forget what TCP does or doesn't do. If you want this functionality then you should implement it as part of your client-server protocol. – Nik Bougalis Feb 28 '13 at 17:55
  • TCP knows how much data has ever been received and buffered by the peer TCP stack. It doesn't know how much has been read by the peer application. – user207421 Mar 01 '13 at 01:34