Question

This doesn't seem to make sense but:

I am on a slow 10 MBPS link. If I initiate sending a large 13 MB file using NIO sockets, and then exit my program, I see that network activity continues for some time.

I would have thought that exiting the process would terminate any sending.

Any ideas?

Was it helpful?

Solution

If there is pending data to be sent when the socket is closed, it will continue to be sent after the socket is closed until either it is all sent or an error occurs. Both writing and closing are asynchronous in TCP.

This is not peculiar to NIO or even Java.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top