Adds error handling for socket writes

Adds SIGPIPE handler which will mark host as offline should a write fail, thereby
triggering SIGPIPE
Also adds global variable representing amount of data
last written to a socket