Refactor sink to handle all events in one for loop: 

* data to send, 
* keep-alive received, 
* timeout reached

are now handled in one select