How to use [`java.net.Socket` **`setKeepAlive(boolean b)`**](https://docs.oracle.com/javase/8/docs/api/java/net/Socket.html#setKeepAlive-boolean-) API?

I am hosting a simple server using `Socket`. 
The clients can connect and send data. I will not close the connection unless the client sends end of stream. The client can continue to hold a connection for any length of time. Data transfer will be going on, but suddenly I see that there is a connection loss without any logs whatsoever. Once the client is restarted (not server), the transmission begins again.
I am not setting any `timeout` as by default it is infinity. I want to understand what `setKeepAlive` actually does so that I will be able to decide whether I need to set that to `true`. 
Can someone help me understand the same? thanks.