|
![]() | 作者: hongyang [hongyang]
![]() |
登录 |
在程序中 "关闭"和设为"零"有什么区别? 比如: CloseHandle(m_hMutex); m_hMutex=NULL; 另外,我在做一个程序后,编译也没有什么错误,但是运行时就是socket创建错误,出现这种情况都是有那些方面的原因?? 谢谢~~~~~~~~~~ |
地主 发表时间: 11/29 22:17 |
![]() | 回复: TomyChen [quest] ![]() |
登录 |
Close通常是把某个句柄关闭。 而m_hMutex = NULL一般是清空(释放指向的地址)。常用于指针 MS使用SOCKET需要进行WSAStartup以及在断开socket后要进去WSACleanup( ); MSDN上例子: WORD wVersionRequested; WSADATA wsaData; int err; wVersionRequested = MAKEWORD( 2, 2 ); err = WSAStartup( wVersionRequested, &wsaData ); if ( err != 0 ) { /* Tell the user that we could not find a usable */ /* WinSock DLL. */ return; } /* Confirm that the WinSock DLL supports 2.2.*/ /* Note that if the DLL supports versions greater */ /* than 2.2 in addition to 2.2, it will still return */ /* 2.2 in wVersion since that is the version we */ /* requested. */ if ( LOBYTE( wsaData.wVersion ) != 2 || HIBYTE( wsaData.wVersion ) != 2 ) { /* Tell the user that we could not find a usable */ /* WinSock DLL. */ WSACleanup( ); return; } /* The WinSock DLL is acceptable. Proceed. */ 另在WIN下编程出错的时候记得用GetLastError得到错误号,然后到MSDN中查找相对应的错误 |
B1层 发表时间: 12/02 21:49 |
|
20CN网络安全小组版权所有
Copyright © 2000-2010 20CN Security Group. All Rights Reserved.
论坛程序编写:NetDemon
粤ICP备05087286号