|
Hum.
in "ChatServerDlg.h"
#define WM_TEST_MESSAGE WM_USER + 100 // define this message
...
afx_msg void OnButtonPingUser();
afx_msg void OnButtonStart();
afx_msg void OnButtonPingAllUsers();
afx_msg void OnButtonDisconnectAllUsers();
//}}AFX_MSG
afx_msg void OnTestMessage(UINT nID, LPARAM lParam); // declaration function
DECLARE_MESSAGE_MAP()
in "ChatServerDlg.cpp"
ON_BN_CLICKED(IDC_BUTTON_PING_USER, OnButtonPingUser)
ON_BN_CLICKED(IDC_BUTTON_START, OnButtonStart)
ON_BN_CLICKED(IDC_BUTTON_PING_ALL_USERS, OnButtonPingAllUsers)
ON_BN_CLICKED(IDC_BUTTON_DISCONNECT_ALL_USERS, OnButtonDisconnectAllUsers)
//}}AFX_MSG_MAP
ON_BN_CLICKED(IDCANCEL, &CChatServerDlg::OnBnClickedCancel)
ON_MESSAGE(WM_TEST_MESSAGE, OnTestMessage) // Add Message to Message Map
END_MESSAGE_MAP()
after compile
error C2440: 'static_cast' : cannot convert from 'void (__thiscall CChatServerDlg::*)(UINT,LPARAM)' to 'LRESULT (__thiscall CWnd::*)(WPARAM,LPARAM)'
error occur...
|
|
|
|
|
You should declare your funtion like this: afx_msg LRESULT OnTestMessage(UINT nID, LPARAM lParam); // declaration function
|
|
|
|
|
thank you!
but when i declare like that occur error!
error LNK2001: unresolved external symbol "public: long __thiscall CSkyAndong_MainDlg::OnTestMessage(unsigned int,long)" (?OnTestMessage@CSkyAndong_MainDlg@@QAEJIJ@Z)
i work at VS6.0. Please help me.
|
|
|
|
|
Dear Sopulee,
In SkyAndong_MainDlg.h you should declare the method as below:
afx_msg LRESULT OnTestMessage(WPARAM, LPARAM);
In SkyAndong_MainDlg.cpp you should make sure that you add the following method:
LRESULT CSkyAndong_MainDlg::OnTestMessage(WPARAM wparam, LPARAM lparam)
{
... //do whatever you want
}
Hope that'll help you.
HQH.
|
|
|
|
|
Hi,
first of all thanks for your work, is a very beautiful project.
I'm trying to use CNDKMessage to exchange messages between two host by network. When application, in host 1, recieves a message, relays it to another MFC application in the same host.
To pass this kind of data I have to use COPYDATASTRUCT and WM_COPYDATA, but to send this message I need to know the size, in bytes, of the message.
Is there a way to retrieve this information?
Thanks a lot
Massimo Germi
|
|
|
|
|
Hi,
I don't understand why you are using WM_COPYDATA to send a message. You can access all attributes of a CNDKMessage, so you can recreate the message easily.
Sébastien
|
|
|
|
|
[Message Deleted due to spam]
|
|
|
|
|
Hi,
In the past, I already heard about this problem. I think that the problem comes from Windows. Please take a look on old comments.
Sébastien
|
|
|
|
|
Great VC network kit.
There is a problem with the server. Wherever there are two clients connected to the server on a network, if one client is receiving big messages from them and meanwhile if any of the users unplucks his cable from the network, the GUI part of the server gets hanged for a long time. I'm unable to do anything on my screen.
Could you provide me with a solution to this problem on the server side?
davidtran71@inbox.com Also, how come the server (chat) is not multi-threaded?
Thanks
|
|
|
|
|
Hi,
The chat provided with the NDK is to show how to use the NDK easily so no thread is used in the sample.
Unfortunately, I don't have the time to debug the problem.
In a real GUI application, you can use the NDK in a thread.
Good luck,
Sébastien
|
|
|
|
|
Do you happen to have a simple Console Application using NDK?
|
|
|
|
|
It works only when an CWinApp is used.
Sébastien
|
|
|
|
|
|
[Message Deleted due to spam]
|
|
|
|
|
|
We thank you .
Your article helped me a lot in studing for the netwoking exam.
Got my 5 definitly.
|
|
|
|
|
Thank you for your comment.
I appreciate it.
Sébastien
|
|
|
|
|
Hi
This is really a fantastic project n i want to use it but the pro is that i m not familiar with c++ n i use vb.net 2005 for my programming needs. so, please tell me how to use the kit with vb.net 2005.
MAP Tiger
Tiger Softwares
Software Designer and Developer
VB.NET, ASP.NET, VFP
|
|
|
|
|
I used the ::GetObject () to get a buffer and contain it's sizes.
client
.....
LPVOID lpData; UINT nSize=0;
HDC hdc = ::GetWindowDC(::GetDesktopWindow());
int Sizebuffer = ::GetObject (&hdc,nSize,&lpData);
message.Add (lpData,Sizebuffer);
......
- it's above code is right to send data as object ?
- how can to implement it in a server , and retrieve data .
Thanks in advance,
|
|
|
|
|
No, that's not correct. Check the code in the Chat Server and the Chat Client. You'll understand.
Sébastien
|
|
|
|
|
hi,
I am working on a robot project. the robot has to communicate with a remote pc, and send and receive infromation such as sound/picture/ and strings. do you think I can use NDK2 for this puspose. if not, what do you suggest.
thank you very much.
|
|
|
|
|
Sure, the use of the NDK in your project will ease the transfert of the sound, picture ans strings.
Take a look at http://www.codeproject.com/internet/NDKFileTransfer.asp
Tell me if you use the NDK 2.0
Sebastien
|
|
|
|
|
If the server disconnect suddenly the client crashes on:
while ((m_pArchiveIn != NULL) &&!m_pArchiveIn->IsBufferEmpty());
So i took the liberty to make some changes:
replace the function CNDKClient::ProcessPendingRead with this
BOOL CNDKClient::ProcessPendingRead(long lErrorCode)<br />
{<br />
BOOL bIsConnectionOpened = TRUE;<br />
try<br />
{<br />
CNDKMessage message;<br />
<br />
if (lErrorCode == 0)<br />
{<br />
do<br />
{<br />
<br />
message.Serialize(*m_pArchiveIn);<br />
<br />
TranslateMessage(message);<br />
<br />
<br />
} while ((m_pArchiveIn != NULL) && !IsBadReadPtr(m_pArchiveIn,sizeof(LPDWORD)) && !IsBadWritePtr(m_pArchiveIn,sizeof(LPDWORD)) &&!m_pArchiveIn->IsBufferEmpty());<br />
}<br />
else<br />
{<br />
if (m_pArchiveOut != NULL)<br />
m_pArchiveOut->Abort();<br />
<br />
CloseConnection(NDKClient_ErrorReceivingMessage);<br />
<br />
bIsConnectionOpened = FALSE;<br />
}<br />
}<br />
catch(CFileException * e)<br />
{<br />
if (m_pArchiveOut != NULL)<br />
m_pArchiveOut->Abort();<br />
<br />
CloseConnection(NDKClient_ErrorReceivingMessage);<br />
<br />
bIsConnectionOpened = FALSE;<br />
}<br />
catch(CArchiveException* e)<br />
{<br />
if (m_pArchiveOut != NULL)<br />
m_pArchiveOut->Abort();<br />
<br />
CloseConnection(NDKClient_ErrorReceivingMessage);<br />
<br />
bIsConnectionOpened = FALSE;<br />
}<br />
catch(...)<br />
{<br />
if (m_pArchiveOut != NULL)<br />
m_pArchiveOut->Abort();<br />
<br />
CloseConnection(NDKClient_ErrorReceivingMessage);<br />
<br />
bIsConnectionOpened = FALSE;<br />
}<br />
return bIsConnectionOpened;<br />
}
this will avoid sudden crashes in the client.
|
|
|
|
|
Thanks for reporting the solution. I did not get this error before.
|
|
|
|
|
there are also memory leaks , can you check this?
NDK.DLL Terminating!<br />
Detected memory leaks!<br />
Dumping objects -><br />
{21885} normal block at 0x0760F580, 260 bytes long.<br />
Data: <NotifyBlockProgr> 4E 6F 74 69 66 79 42 6C 6F 63 6B 50 72 6F 67 72 <br />
{21881} normal block at 0x075D57C0, 260 bytes long.<br />
Data: <NotifyBlockProgr> 4E 6F 74 69 66 79 42 6C 6F 63 6B 50 72 6F 67 72 <br />
{21877} normal block at 0x07611C40, 260 bytes long.<br />
Data: <NotifyBlockProgr> 4E 6F 74 69 66 79 42 6C 6F 63 6B 50 72 6F 67 72 <br />
{15095} normal block at 0x0760F2E0, 20 bytes long.<br />
Data: <X F o r m O u > 58 00 46 00 6F 00 72 00 6D 00 20 00 4F 00 75 00 <br />
{15094} normal block at 0x0760F290, 16 bytes long.<br />
Data: <$ ` > 24 1C 94 09 00 00 00 00 FF 01 00 00 00 F1 60 07 <br />
{15093} normal block at 0x0760F1A0, 176 bytes long.<br />
Data: <D$ ` > 44 24 94 09 FF 01 00 00 A0 F1 60 07 00 00 00 00 <br />
{15092} normal block at 0x0760F150, 18 bytes long.<br />
Data: <X F o r m I n > 58 00 46 00 6F 00 72 00 6D 00 20 00 49 00 6E 00 <br />
{15091} normal block at 0x0760F100, 16 bytes long.<br />
Data: < a > DC 1B 94 09 00 00 00 00 FE 01 00 00 10 0D 61 07 <br />
{15090} normal block at 0x0760EFD8, 232 bytes long.<br />
Data: < # ` > 9C 23 94 09 FE 01 00 00 D8 EF 60 07 00 00 00 00 <br />
{15086} normal block at 0x07611FD8, 16 bytes long.<br />
Data: < > 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <br />
{15084} normal block at 0x07610D10, 16 bytes long.<br />
Data: < ?a > 1C 14 94 09 00 00 00 00 FB 01 00 00 10 3F 61 07 <br />
{15083} normal block at 0x0760EDE8, 232 bytes long.<br />
Data: < ` > B4 13 94 09 FB 01 00 00 E8 ED 60 07 01 00 00 00 <br />
{15067} normal block at 0x075D52D8, 36 bytes long.<br />
Data: < > EA 03 00 00 00 04 00 00 00 05 00 00 00 00 00 00 <br />
{14500} normal block at 0x076108B8, 20 bytes long.<br />
Data: <X F o r m O u > 58 00 46 00 6F 00 72 00 6D 00 20 00 4F 00 75 00 <br />
{14499} normal block at 0x07613F10, 16 bytes long.<br />
Data: <$ a > 24 1C 94 09 00 00 00 00 8C 01 00 00 08 1F 61 07 <br />
{14498} normal block at 0x07614F08, 176 bytes long.<br />
Data: <D$ Oa > 44 24 94 09 8C 01 00 00 08 4F 61 07 00 00 00 00 <br />
{14497} normal block at 0x07613EC0, 18 bytes long.<br />
Data: <X F o r m I n > 58 00 46 00 6F 00 72 00 6D 00 20 00 49 00 6E 00 <br />
{14496} normal block at 0x07611F08, 16 bytes long.<br />
Data: < T] > DC 1B 94 09 00 00 00 00 8B 01 00 00 C8 54 5D 07 <br />
{14495} normal block at 0x07610790, 232 bytes long.<br />
Data: < # a > 9C 23 94 09 8B 01 00 00 90 07 61 07 00 00 00 00 <br />
{14491} normal block at 0x075DB7F0, 16 bytes long.<br />
Data: < > 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <br />
{14489} normal block at 0x075D54C8, 16 bytes long.<br />
Data: < %a > 1C 14 94 09 00 00 00 00 88 01 00 00 20 25 61 07 <br />
{14488} normal block at 0x07611D90, 232 bytes long.<br />
Data: < a > B4 13 94 09 88 01 00 00 90 1D 61 07 01 00 00 00 <br />
{14472} normal block at 0x076125C0, 36 bytes long.<br />
Data: < > EA 03 00 00 00 04 00 00 00 05 00 00 00 00 00 00 <br />
{2530} normal block at 0x07612570, 20 bytes long.<br />
Data: <X F o r m O u > 58 00 46 00 6F 00 72 00 6D 00 20 00 4F 00 75 00 <br />
{2529} normal block at 0x07612520, 16 bytes long.<br />
Data: <$ y #a > 24 1C 94 09 00 00 00 00 79 00 00 00 90 23 61 07 <br />
{2528} normal block at 0x07612430, 176 bytes long.<br />
Data: <D$ y 0$a > 44 24 94 09 79 00 00 00 30 24 61 07 00 00 00 00 <br />
{2527} normal block at 0x076123E0, 18 bytes long.<br />
Data: <X F o r m I n > 58 00 46 00 6F 00 72 00 6D 00 20 00 49 00 6E 00 <br />
{2526} normal block at 0x07612390, 16 bytes long.<br />
Data: < x P!a > DC 1B 94 09 00 00 00 00 78 00 00 00 50 21 61 07 <br />
{2525} normal block at 0x07612268, 232 bytes long.<br />
Data: < # x h"a > 9C 23 94 09 78 00 00 00 68 22 61 07 00 00 00 00 <br />
{2521} normal block at 0x07611F88, 16 bytes long.<br />
Data: < > 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <br />
{2519} normal block at 0x07612150, 16 bytes long.<br />
Data: < u P a > 1C 14 94 09 00 00 00 00 75 00 00 00 50 19 61 07 <br />
{2518} normal block at 0x07612028, 232 bytes long.<br />
Data: < u ( a > B4 13 94 09 75 00 00 00 28 20 61 07 01 00 00 00 <br />
{2502} normal block at 0x076115F8, 36 bytes long.<br />
Data: < > EA 03 00 00 00 04 00 00 00 05 00 00 00 00 00 00 <br />
{1935} normal block at 0x076119A0, 20 bytes long.<br />
Data: <X F o r m O u > 58 00 46 00 6F 00 72 00 6D 00 20 00 4F 00 75 00 <br />
{1934} normal block at 0x07611950, 16 bytes long.<br />
Data: <$ a > 24 1C 94 09 00 00 00 00 06 00 00 00 C0 17 61 07 <br />
{1933} normal block at 0x07611860, 176 bytes long.<br />
Data: <D$ ` a > 44 24 94 09 06 00 00 00 60 18 61 07 00 00 00 00 <br />
{1932} normal block at 0x07611810, 18 bytes long.<br />
Data: <X F o r m I n > 58 00 46 00 6F 00 72 00 6D 00 20 00 49 00 6E 00 <br />
{1931} normal block at 0x076117C0, 16 bytes long.<br />
Data: < a > DC 1B 94 09 00 00 00 00 05 00 00 00 A8 15 61 07 <br />
{1930} normal block at 0x07611698, 232 bytes long.<br />
Data: < # a > 9C 23 94 09 05 00 00 00 98 16 61 07 00 00 00 00 <br />
{1926} normal block at 0x075D5220, 16 bytes long.<br />
Data: < > 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <br />
{1924} normal block at 0x076115A8, 16 bytes long.<br />
Data: < > 1C 14 94 09 00 00 00 00 02 00 00 00 00 00 00 00 <br />
{1923} normal block at 0x07611480, 232 bytes long.<br />
Data: < a > B4 13 94 09 02 00 00 00 80 14 61 07 01 00 00 00 <br />
{1907} normal block at 0x075D5918, 36 bytes long.<br />
Data: < > EA 03 00 00 00 04 00 00 00 05 00 00 00 00 00 00 <br />
f:\sp\vctools\vc7libs\ship\atlmfc\src\mfc\strcore.cpp(141) : {924} normal block at 0x075DDD48, 42 bytes long.<br />
Data: <, ?x > 2C 08 3F 78 19 00 00 00 19 00 00 00 01 00 00 00 <br />
{533} normal block at 0x075C3800, 40 bytes long.<br />
Data: <Lv; \ > 4C 76 3B 06 CD CD CD CD 98 1D 5C 07 00 00 00 00 <br />
{526} normal block at 0x075C1E38, 1168 bytes long.<br />
Data: <p > 70 1E 00 00 00 00 00 00 01 00 00 00 02 00 00 00 <br />
Object dump complete.
|
|
|
|
|