Browse Source

修改crc校验的计算错误

zzj 6 years ago
parent
commit
fe871c8160
2 changed files with 4 additions and 4 deletions
  1. 3 3
      znet.cpp
  2. 1 1
      znet.h

+ 3 - 3
znet.cpp

@@ -180,7 +180,7 @@ struct sock_client:fd_io,client_ex
 	io_context&m_ic;
 	std::string m_name;
 	std::atomic<bool> m_close_flag{false};
-	int   m_type=0;//site
+	int   m_type=1;//site
 
 	char  *m_b{0};
 	int   m_clen{0};
@@ -443,7 +443,7 @@ struct sock_client:fd_io,client_ex
 		crc<<=8;
 		crc|=b[mlen-1];
 
-		if(do_crc((unsigned char*)b,mlen)==crc)
+		if(do_crc((unsigned char*)b+2,mlen-4)==crc)
 			return true;
 
 		return false;
@@ -527,7 +527,7 @@ struct main_loop:io_context
 
 		sock_listen _1(*this,fd);
 
-		stdin_io _2(*this);
+//		stdin_io _2(*this);
 
 		block_sig(SIGPIPE);
 		signal_w sint(*this,SIGINT),term(*this,SIGTERM);

+ 1 - 1
znet.h

@@ -8,7 +8,7 @@
 struct client:std::enable_shared_from_this<client>
 {
 	virtual std::string name()=0;
-	virtual int type()=0;			//分站:0,WEB:1
+	virtual int type()=0;			//分站:1,模拟客户端:2
 	virtual int handle()=0;
 
 	virtual void close()=0;