agent: fix crash with debugging enabled

For some connection types nicesock->fileno is never set.
Make sure it is not NULL before using it.
1 job for debug-segv in 1 minute and 6 seconds (queued for 3 seconds)
Status Job ID Name Coverage
  Build
passed #31610
build-and-test

00:01:06