Only use snprintf, not strlcpy.  Include <stdio.h>.

Noticed by Alain-Pierre Perrin.
Add <errno.h> for ETIMEDOUT.

Noticed by Alain-Pierre Perrin.