handle socket error (for issue #7)

Same as #7, I got <code>[Errno 57] Socket is not connected</code> when i using mac os with SocketNER.
I add error handling code for that, and it works fine now.