2011年12月22日
摘要: 1.首先将标志位设为Non-blocking模式,准备在非阻塞模式下调用connect函数 2.调用connect,正常情况下,因为TCP三次握手需要一些时间;而非阻塞调用只要不能立即完成就会返回错误,所以这里会返回EINPROGRESS,表示在建立连接但还没有完成。 3.在读套接口描述符集(fd_set rset)和写套接口描述符集(fd_set wset)中将当前套接口置位(用FD_ZERO()、FD_SET()宏),并设置好超时时间(struct timeval *timeout) 4.调用select( socket, &rset, &wset, NULL, timeo 阅读全文
posted @ 2011-12-22 17:08 Msisterc 阅读(5246) 评论(0) 推荐(0) 编辑
2011年12月20日
摘要: 1. CString 转 wchar_tCString path = "asdf";wchar_t wstr[256] = path.AllocSysString();或者:wchar_t wcstring[256];MultiByteToWideChar(CP_ACP,0,path,-1,wcstring,256);2. wchar_t转CStringWideCharToMultiByte(CP_ACP,0,wcstring,256,path.GetBuffer(0),256,NULL,NULL);path.ReleaseBuffer(0);3. string 转 CSt 阅读全文
posted @ 2011-12-20 17:17 Msisterc 阅读(1363) 评论(0) 推荐(0) 编辑
摘要: 标准CRC生成多项式如下表:名称生成多项式简记式*标准引用 CRC-4 x4+x+1 3 ITU G.704 CRC-8 x8+x5+x4+1 0x31 CRC-8 x8+x2+x1+1 0x07 CRC-8 x8+x6+x4+x3+x2+x1 0x5E CRC-12 x12+x11+x3+x+1 80F CRC-16 x16+x15+x2+1 8005 IBM SDLC CRC16-CCITT x16+x12+x5+1 1021 ISO HDLC, ITU X.25, V.34/V.41/V.42, PPP-FCS CRC-32 x32+x26+x23+...+x2+x+1 04C11DB7 阅读全文
posted @ 2011-12-20 17:02 Msisterc 阅读(121960) 评论(4) 推荐(5) 编辑