hi im trying to create a server program to recieve and send text msgs to and from clients. im trying to create a seperate thread for the function that listens to clients, so that the server can also send data while it listen. i create the thread like this:
Code:
void CServerDlg::OnBnClickedBstart()
{
HANDLE hT1 = CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)ListenToClient,NULL,0,NULL);
WaitForSingleObject(hT1, INFINITE);
}
but when thread starts, the program hangs (because of the infinite loop inside the ListenToClient() function). (ListenToClient() is not a class function.) so creating a different thread like this dosen't seems to work with MFC? so how can i run ListenToClient() seperately so it dosen't hangs programs' UI?
thanks for any help.