Improve socket error handling, send op:leave on error