LGTM. Only comment is that in some places your calls to log_msg() have multiple NLs specified which will look odd when logged to syslog. For example:
if (response > 200)
log_msg ("Server replied with:\n%s\n", s.p);
This will result in all except the last '\n's displaying in syslog as "#012" which probably isn't what you want. I guess the easiest solution is to just make 2 calls to log_msg() in those scenarios.
LGTM. Only comment is that in some places your calls to log_msg() have multiple NLs specified which will look odd when logged to syslog. For example:
if (response > 200)
log_msg ("Server replied with:\n%s\n", s.p);
This will result in all except the last '\n's displaying in syslog as "#012" which probably isn't what you want. I guess the easiest solution is to just make 2 calls to log_msg() in those scenarios.