Browse Source

修改crc计算的bug

zzj 6 years ago
parent
commit
7cba8daebf
1 changed files with 4 additions and 4 deletions
  1. 4 4
      znet.cpp

+ 4 - 4
znet.cpp

@@ -437,16 +437,16 @@ struct sock_client:fd_io,client_ex
 		}
 	}
 
-	bool check_crc(const char*b,size_t mlen)
+	bool check_crc(void *b0,size_t mlen)
 	{
+		uint8_t*b=(uint8_t*)b0;
 		uint16_t crc=b[mlen-2];
 		crc<<=8;
 		crc|=b[mlen-1];
 
-		if(do_crc((unsigned char*)b+2,mlen-4)==crc)
-			return true;
+		uint16_t ccrc=do_crc((unsigned char*)b+2,mlen-4);
 
-		return false;
+		return ccrc==crc;
 	}
 
 	void on_message(const char*m,int mlen)