Handle socket error: invoke all pending callbacks