Refactor version check into separate function. Check version on client too. This allows to connect to remote servers with different version (0 for old servers) and fail early if versions mismatch.