Billar
June 13th, 2004, 01:28 AM
Dear Friends,
I am using CAsyncSocket and CSocket for writting a server program. In AsyncSocket I am using
virtual void OnAccept(int nErrorCode);
virtual void OnClose(int nErrorCode);
virtual void OnReceive(int nErrorCode); and also in Socket I am using
virtual void OnAccept(int nErrorCode);
virtual void OnClose(int nErrorCode);
virtual void OnConnect(int nErrorCode);
virtual void OnReceive(int nErrorCode);
Also in the dlg.cpp file,
At InitDialog I am writting
m_cSocketServer.Create(4000);
m_cSocketServer.Listen();
m_cAsyncSocketServer.Create(4000);
m_cSocketServer.Listen();
Also at the Onbutton message I am checking and writting a message into a display like this
void CMFCServerDlg::OnButtonConnection()
{
// TODO: この位置にコントロール通知ハンドラ用のコードを追加して_ださい
char DispBuf[256];
if(m_cSocketServer.Create(4000) && m_cSocketServer.Listen()){
sprintf(DispBuf, "Server Started");
AfxGetMainWnd()->GetDlgItem(IDC_STATIC)->SetWindowText(DispBuf);
}
else{
sprintf(DispBuf, "Connection Failed");
AfxGetMainWnd()->GetDlgItem(IDC_STATIC)->SetWindowText(DispBuf);
}
For other reference....
LRESULT CMFCServerDlg::OnAccept(WPARAM wParam, LPARAM lParam)
{
m_cSocketServer.Accept(m_cAsyncSocketServer);
DestroyFlag = TRUE;
return 0;
}
This is a user message send by the AsyncSocket and Socket from OnAcceptMessage....
My applicaion is very simple and with the above code it is not working. Will you please help to detect the error. Why this code is not suitable to develop a simple server.
Here, I have a dialog box with one button and a text box. Button is for to start a server and text box is nothing but to display a message that server is started.
Please help me to find out the solution.
Thanking You in advance.
Billar
:thumb: :mad: :confused:
I am using CAsyncSocket and CSocket for writting a server program. In AsyncSocket I am using
virtual void OnAccept(int nErrorCode);
virtual void OnClose(int nErrorCode);
virtual void OnReceive(int nErrorCode); and also in Socket I am using
virtual void OnAccept(int nErrorCode);
virtual void OnClose(int nErrorCode);
virtual void OnConnect(int nErrorCode);
virtual void OnReceive(int nErrorCode);
Also in the dlg.cpp file,
At InitDialog I am writting
m_cSocketServer.Create(4000);
m_cSocketServer.Listen();
m_cAsyncSocketServer.Create(4000);
m_cSocketServer.Listen();
Also at the Onbutton message I am checking and writting a message into a display like this
void CMFCServerDlg::OnButtonConnection()
{
// TODO: この位置にコントロール通知ハンドラ用のコードを追加して_ださい
char DispBuf[256];
if(m_cSocketServer.Create(4000) && m_cSocketServer.Listen()){
sprintf(DispBuf, "Server Started");
AfxGetMainWnd()->GetDlgItem(IDC_STATIC)->SetWindowText(DispBuf);
}
else{
sprintf(DispBuf, "Connection Failed");
AfxGetMainWnd()->GetDlgItem(IDC_STATIC)->SetWindowText(DispBuf);
}
For other reference....
LRESULT CMFCServerDlg::OnAccept(WPARAM wParam, LPARAM lParam)
{
m_cSocketServer.Accept(m_cAsyncSocketServer);
DestroyFlag = TRUE;
return 0;
}
This is a user message send by the AsyncSocket and Socket from OnAcceptMessage....
My applicaion is very simple and with the above code it is not working. Will you please help to detect the error. Why this code is not suitable to develop a simple server.
Here, I have a dialog box with one button and a text box. Button is for to start a server and text box is nothing but to display a message that server is started.
Please help me to find out the solution.
Thanking You in advance.
Billar
:thumb: :mad: :confused: