shahzadalam
April 10th, 1999, 05:40 AM
Sir what could be wrong there in this code
I want to develop a multithreaded server that connects to multiple clients
and sends them a proper message.
Now I am using the AfxBeginThread(....) .
I have declared two objects of CSocket
1. CSocket m_sListenSocket(); for listening in the header file of newServerDlg.h
2.and the other in the cpp file my main dialog which is as
// newServerDlg.cpp : implementation file
.......
......
CSocket m_sConnectSocket;
.....
......
void CNewServerDlg::OnButStartServer()
{
// TODO: Add your control notification handler code here
m_sListenSocket.Create(25);
BOOL Let_me_Listen = TRUE;
while (Let_me_Listen == TRUE)
{
m_sListenSocket.Listen();
m_sListenSocket.Accept(m_sConnectSocket);
AfxMessageBox("accepted");
CWinThread* newThread = AfxBeginThread(threadfunction, GetSafeHwnd(), THREAD_PRIORITY_NORMAL);
}
}
UINT CNewServerDlg::threadfunction(LPVOID pParam)
{
CString sTemp = "220 192.168.0.14 Service Ready";
m_sConnectSocket.Send( (LPCTSTR)sTemp, sTemp.GetLength() );
m_sConnectSocket.Close();
return 0;
}
Now there is no compile error but when I run it and a client is connected to it it is accepted.
the message is sent to client but then three Degug Assertion Failed errors are there
1. sockcore.cpp line no 177
2.sockcore.cpp line no 178
3.sockcore.cpp line no 407
I want to develop a multithreaded server that connects to multiple clients
and sends them a proper message.
Now I am using the AfxBeginThread(....) .
I have declared two objects of CSocket
1. CSocket m_sListenSocket(); for listening in the header file of newServerDlg.h
2.and the other in the cpp file my main dialog which is as
// newServerDlg.cpp : implementation file
.......
......
CSocket m_sConnectSocket;
.....
......
void CNewServerDlg::OnButStartServer()
{
// TODO: Add your control notification handler code here
m_sListenSocket.Create(25);
BOOL Let_me_Listen = TRUE;
while (Let_me_Listen == TRUE)
{
m_sListenSocket.Listen();
m_sListenSocket.Accept(m_sConnectSocket);
AfxMessageBox("accepted");
CWinThread* newThread = AfxBeginThread(threadfunction, GetSafeHwnd(), THREAD_PRIORITY_NORMAL);
}
}
UINT CNewServerDlg::threadfunction(LPVOID pParam)
{
CString sTemp = "220 192.168.0.14 Service Ready";
m_sConnectSocket.Send( (LPCTSTR)sTemp, sTemp.GetLength() );
m_sConnectSocket.Close();
return 0;
}
Now there is no compile error but when I run it and a client is connected to it it is accepted.
the message is sent to client but then three Degug Assertion Failed errors are there
1. sockcore.cpp line no 177
2.sockcore.cpp line no 178
3.sockcore.cpp line no 407