AB - Altered to handle socket failure better.