prati
December 2nd, 2004, 12:11 AM
Hello!
Im Implementing an application with socket programming.I have a menu item when i click on item i get dialog box ,that dialog box i have called from the function which has been called from the selection of the menu item.
eg..
/////////////////////////////////////////////////////////////////////////////////////////
OnMenuItem()
{
CMyDialog dlg;
dlg.DoModal(); //some action to be performed in dialog
---------
-------- //wait till get response from socket // some action to be performed based on response.
}
/////////////////////////////////////////////////////////////////////////////////////////
In OnOK() function of the dialog, i have called another function say sockets send() function and then return back to the function from which the dialog box called and continues to that function.But here i want to wait till i get response from the socket,i have implemented receive() function for it which is independent function.
________________________________________________________________
PROBLEM :
_________
Problem is that when i returned to the calling function of the dlg.DoModal() it immidiately continues to the same function ,although i have sent the data to the server socket, then the receive function should get the response from the server socket independently , but when i put the break points to these functions i found it continues to the function first and then receives the response, which i don't want. So i have put Sleep(1000) function after dlg.DoModal() but nothing has happened. Receive() function never receives the response before returning from the function which has called dlg.DoModal().
________________________________________________________________
So please tell me the way how to synchronize the things so that i can receive the response from the socket at one hand and after that, continues to the function on the other hand.
Prati.
Im Implementing an application with socket programming.I have a menu item when i click on item i get dialog box ,that dialog box i have called from the function which has been called from the selection of the menu item.
eg..
/////////////////////////////////////////////////////////////////////////////////////////
OnMenuItem()
{
CMyDialog dlg;
dlg.DoModal(); //some action to be performed in dialog
---------
-------- //wait till get response from socket // some action to be performed based on response.
}
/////////////////////////////////////////////////////////////////////////////////////////
In OnOK() function of the dialog, i have called another function say sockets send() function and then return back to the function from which the dialog box called and continues to that function.But here i want to wait till i get response from the socket,i have implemented receive() function for it which is independent function.
________________________________________________________________
PROBLEM :
_________
Problem is that when i returned to the calling function of the dlg.DoModal() it immidiately continues to the same function ,although i have sent the data to the server socket, then the receive function should get the response from the server socket independently , but when i put the break points to these functions i found it continues to the function first and then receives the response, which i don't want. So i have put Sleep(1000) function after dlg.DoModal() but nothing has happened. Receive() function never receives the response before returning from the function which has called dlg.DoModal().
________________________________________________________________
So please tell me the way how to synchronize the things so that i can receive the response from the socket at one hand and after that, continues to the function on the other hand.
Prati.