wrap calls to read() to ensure reading the expected amount of data or failing

while still handling the case of read() being interrupted
or reading less bytes than expected

also ensure removing sockets using for chk and sts commands in case of failure