测试主机端口

BOOL CenumhostsDlg::TestConnection(CString IP, UINT nPort)
{
 CSocket* pSocket;
 pSocket=new CSocket();
 ASSERT(pSocket);
 if(!pSocket->Create())
 {
  delete pSocket;
  pSocket=NULL;
  return false;

 }

 while(!pSocket->Connect(IP,nPort))
 {
  delete pSocket;
  pSocket=NULL;
  return false;
 }

 pSocket->Close();
 delete pSocket;
 
 return true;

你可能感兴趣的:(测试,delete,null)