最近在写MFC的网络编程,不启动服务端,启动客户端的时候,会有内存泄漏,代码如下:
sockaddr_in addr;
addr.sin_family = AF_INET;
addr.sin_port = htons(nPort);
addr.sin_addr.S_un.S_addr = inet_addr(strAddr);
ULONG argp = 1;
ioctlsocket(m_s,FIONBIO,&argp); // 设置非阻塞模式
connect(m_s,(LPSOCKADDR)&addr,sizeof(addr));
TIMEVAL timeout;
timeout.tv_sec = _TIME_OUT;
timeout.tv_usec = 0 ;
fd_set set;
FD_ZERO(&set);
FD_SET(m_s,&set);
if ( 0 == select(0,NULL,&set,NULL,&timeout) )
{
//内存泄漏
FD_CLR(m_s,&set);
m_bTimeOut = TRUE;
return -1;
}
select 语句失败时,会有内存泄漏,求大神帮忙看一下啊