Message handler catches socket errors