Execute a callback on socket errors