Turns out I confused using Socket.setSoLinger()
as my connection timeout setting causing the long hang thus TimeoutException. :/
This is what Socket.setSoLinger()
does:
If the socket is in connection-mode, and the SO_LINGER option is set for the socket with non-zero linger time, and the socket has untransmitted data, then close() shall block for up to the current linger interval until all data is transmitted.
http://pubs.opengroup.org/onlinepubs/009695399/functions/close.html