Prevent to raise Errno::ENOTCONN if no client connected

Small refactoring

Change-Id: I500e3e30b5678b5ce126573cb3e2b360a490b155
Closes-Bug: #1290741