Fixes a socket error.

> I'm just checking to avoid error messages

Can you explain in what state you receive error messages without having that check? That's what I'm not understanding.