Bug 1010748 - Detect that the socket closed.

This work around a hang (infinite loop) when b2g crashes.