Click here to Skip to main content
15,926,507 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Small Challenge for all you experts Pin
bikram singh13-Jun-04 19:35
bikram singh13-Jun-04 19:35 
GeneralRe: Small Challenge for all you experts Pin
Ravi Bhavnani13-Jun-04 11:53
professionalRavi Bhavnani13-Jun-04 11:53 
GeneralRe: Small Challenge for all you experts Pin
bikram singh13-Jun-04 19:32
bikram singh13-Jun-04 19:32 
GeneralRe: Small Challenge for all you experts Pin
Ravi Bhavnani14-Jun-04 1:26
professionalRavi Bhavnani14-Jun-04 1:26 
GeneralRe: Small Challenge for all you experts Pin
bikram singh14-Jun-04 2:54
bikram singh14-Jun-04 2:54 
GeneralDone it ! Pin
bikram singh14-Jun-04 3:01
bikram singh14-Jun-04 3:01 
Questionhow to add menu on dialog? Pin
vividtang13-Jun-04 1:19
vividtang13-Jun-04 1:19 
AnswerRe: how to add menu on dialog? Pin
bikram singh13-Jun-04 1:33
bikram singh13-Jun-04 1:33 
GeneralRe: how to add menu on dialog? Pin
toxcct13-Jun-04 3:05
toxcct13-Jun-04 3:05 
AnswerRe: how to add menu on dialog? Pin
toxcct13-Jun-04 3:02
toxcct13-Jun-04 3:02 
AnswerRe: how to add menu on dialog? Pin
Johan Rosengren13-Jun-04 3:07
Johan Rosengren13-Jun-04 3:07 
QuestionA window never get focus? Pin
uniqueworld13-Jun-04 0:51
uniqueworld13-Jun-04 0:51 
AnswerRe: A window never get focus? Pin
bikram singh13-Jun-04 1:31
bikram singh13-Jun-04 1:31 
AnswerRe: A window never get focus? Pin
toxcct13-Jun-04 3:08
toxcct13-Jun-04 3:08 
GeneralRe: A window never get focus? Pin
Behzad Ebrahimi13-Jun-04 4:24
Behzad Ebrahimi13-Jun-04 4:24 
GeneralRe: A window never get focus? Pin
toxcct13-Jun-04 4:27
toxcct13-Jun-04 4:27 
GeneralRe: A window never get focus? Pin
Behzad Ebrahimi13-Jun-04 4:38
Behzad Ebrahimi13-Jun-04 4:38 
Generalgif format Pin
includeh1012-Jun-04 22:50
includeh1012-Jun-04 22:50 
GeneralRe: gif format Pin
Johan Rosengren12-Jun-04 23:38
Johan Rosengren12-Jun-04 23:38 
GeneralUrgent Requirement-Socket Programming Pin
Billar12-Jun-04 19:18
Billar12-Jun-04 19:18 
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



GeneralRe: Urgent Requirement-Socket Programming Pin
includeh1012-Jun-04 22:59
includeh1012-Jun-04 22:59 
GeneralRe: Urgent Requirement-Socket Programming Pin
Billar12-Jun-04 23:29
Billar12-Jun-04 23:29 
GeneralRe: Urgent Requirement-Socket Programming Pin
Yulianto.13-Jun-04 16:18
Yulianto.13-Jun-04 16:18 
GeneralCAsyncSocket Server Pin
Billar12-Jun-04 18:03
Billar12-Jun-04 18:03 
GeneralRe: CAsyncSocket Server Pin
toxcct13-Jun-04 3:12
toxcct13-Jun-04 3:12 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.