Handle socket errors