当前位置: 技术问答>linux和unix
服务器端关闭,客户端select 会一直可读, 读的长度是-1,怎么在不关闭客户端socket下,清除可读
来源: 互联网 发布时间:2016-07-07
本文导语: int nRetVal = select( m_nSocket + 1 , &rfd , NULL, NULL , &tv ); //int nRetVal = select( m_nSocket + 1 , &rfd , &wfd , NULL , &tv ); if ( -1 == nRetVal ) { printf( "CListonSocket::Select Errorn" ); return false; } else if (nRetVal ==...
int nRetVal = select( m_nSocket + 1 , &rfd , NULL, NULL , &tv );
//int nRetVal = select( m_nSocket + 1 , &rfd , &wfd , NULL , &tv );
if ( -1 == nRetVal )
{
printf( "CListonSocket::Select Errorn" );
return false;
}
else if (nRetVal == 0)
{
//printf("select timeout!n");
return true;
}
if (!m_bThreadStart)
return true;
if (FD_ISSET(m_nSocket, &rfd))
{
if (m_lNetworkEvt & FD_ACCEPT)
{
OnAccept();
//printf("OnAccept!n");
}
if (m_lNetworkEvt & FD_READ)
OnRecieved();//
//int nRetVal = select( m_nSocket + 1 , &rfd , &wfd , NULL , &tv );
if ( -1 == nRetVal )
{
printf( "CListonSocket::Select Errorn" );
return false;
}
else if (nRetVal == 0)
{
//printf("select timeout!n");
return true;
}
if (!m_bThreadStart)
return true;
if (FD_ISSET(m_nSocket, &rfd))
{
if (m_lNetworkEvt & FD_ACCEPT)
{
OnAccept();
//printf("OnAccept!n");
}
if (m_lNetworkEvt & FD_READ)
OnRecieved();//