Home > Software engineering >  Everybody to help me take a look at the code, why always create failure?
Everybody to help me take a look at the code, why always create failure?

Time:10-07

 class CSrvSock: public CSocket 

CSrvSock: : CSrvSock (CDialog * pServerDlg)
{
M_pServerDlg=(CServerDlg *) pServerDlg;
}

M_pServerSock=new CSrvSock (this);

M_pServerSock - & gt; Create (m_uPort SOCK_STREAM, m_strIP)

M_pServerSock - & gt; Listen ()


Everybody to help me take a look at the code, why always create failure?

CodePudding user response:

AfxSocketInit is there? GetLastError can view the error message

CodePudding user response:

Initialize the system socket library

CodePudding user response:

Sure you your error phenomenon, as a result, the question again,

Win a Socket operation failed, call WSAGetLastError. See the error code,
To https://msdn.microsoft.com/en-us/library/windows/desktop/ms740668 (v=v., 85). Aspx, according to the error code, find the reason for the error,

CodePudding user response:

Which step go wrong, you can check the return value of the error function
  • Related