Bugfixing.

If the connection ends with a socket error emit the 'error' event with the description of it.