1

I have two sockets connected, and the first socket has just sent the second socket 20 MB of data. Now the user has decided that he wants to close the connection, so the first socket sends a FIN to the second socket.

Now the problem is that the FIN will only be processed by the second socket once the 2 MB of data has be fully received (which could take no less than 10 minutes!).

So how can I close the connection immediately, should I send an RST instead of a FIN? and is there any issues in sending an RST (other than the fact that the 2 MB of data will be discarded)?

user6088487
  • 189
  • 6
  • RST will close the connection and drop all data in flight in both directions. FIN will close the connection after all data in flight has been received. Hard to see why you would send 2MB and then want to abort the send, but if that's what you want, use RST. Nothing else will do it for you. – user207421 Mar 20 '16 at 06:27
  • 1
    Related: http://stackoverflow.com/q/13049828/694576 – alk Mar 20 '16 at 06:42
  • @EJP *"Hard to see why you would send 2MB and then want to abort the send"* For example: the user could be uploading a file and then he find out that he selected the wrong file, and so he aborts the upload. – user6088487 Mar 20 '16 at 06:46
  • 1
    Look for "*abortive close*" (http://stackoverflow.com/q/3757289/694576). – alk Mar 20 '16 at 07:04
  • However separating control flow from data flow might be an alternative approach to solve this use-case on application level (see FTP). – alk Mar 20 '16 at 07:06

0 Answers0