java - NIO: Send message and then disconnect immediately -
Under some circumstances, I want to send an error message from a server using non-blocked I / O (
) SocketChannel.write (ByteBuffer)
) and then disconnect the client I will write the entire contents and then disconnect immediately that I believe the customer can not be to receive this message because I think the OS has not actually sent data at this point . Is that correct, and if there is a recommended approach to dealing with this situation?
I was thinking of using a clock so that I want to disconnect a customer, then close their connection after 1-2 seconds.