Add socket.writable check before writing to the socket

Signed-off-by: Mario Kozjak <kozjakm1@gmail.com>