I was trying to start a brand new dialog based program to include your NDK Classes. I've already transferred all the NDK files(headers and source files) to my Client folder(name of program is Client) and added the .cpp and .h file to the VC6 program. I've also included (#include "NDKClient.h" ) in ClientDlg.h. However, when I tried to establish connection by using OpenConnection and IsStarted, I get the following error:
First of all, thank you for making these source codes available.
Secondly, I hope to use your source codes to transfer numerical information for eg. joystick position, speed of a car, etc from the server to the client. Do I first store them in a buffer? Are the source codes for doing the above found in CNDKMessage or CNDKDatabuffer? I'm aware that your project works very well for chats but could you give me some clues to how I can send data from the server to the client. Basically, there won't be someone at the server side who will type in the numerical values and hit [Send]. Any help at all will be appreciated. Thanks so much.
I use NDK 2.0 to handle all of the underlying network traffic in my 3D freeware port of the board game Settlers of Catan (at http://www.settlers3d.net). It's been in use for over a year now and it's been very solid! Just thought you'd like to know that your code has been used by thousands of people playing my game!
Nice and easy to use and well written, that's true!!!
But there's a problem for my application:
I want to transport data from the client to the server which should compute the results and write them back to the client. Two packets are needed, the first is the request packet from client to server and the second contains the results from the server to the client. A remote precedure call, not surprising...
The client is a console application. A function CMyNDKClient::CallServerFunctionA() should do the whole work. It is sending the request and should get the expected answer from the server. But the answer returns in CMyNDKClient::OnMessage(), of course, it's the callback.
Hmmh, but how to pass the answer to the first function? By letting the first function sleep until the data has arrived in OnMessage()??? OnMessage() could set a flag or an event to inform the first function about it's data arrival. But this does not work because both Sleep() or WaitForSingleObject() move the thread away from the CPU, and the message did not arrive in OnMessage(). It appears only after the wait period has elapsed and the first function was left.
So, are there waitable objects in socket communication? Do I have to use different threads for this? Do I have to write own in and out queues processed by different worker threads? Or how can I split sending and receiving in two thread?
PS: I believe this problem has been the real topic in a previous question 'How can I force my client to wait for a server answer !? by Damien Cohas, half a year ago.
Also on doubt about how client wait for server's response
Posted by cowell
on 06/23/2009 11:16pm
I also met this problem. Can Someone answer this or
give another solution to that?
I wrote a distributed program that is made up of a client and a server.
Essentially the client sends a message to the server every minute. The server make some processing then sends back a message to the client.
For some weird reason after few hours the communication hangs. Using log files I've noticed that the client continues to send message to the server that no more receives it! It seems that the OnReceive method of the server is not even called.
Reading other comments I've seen that the problem could be due to the using of Visual Studio.NET.
After few modifications I successfully recompiled the server using Visual C++ 6.0 but unfortunately a I can't do the same with the client. It uses some specific features of MFC 7.
After the recompilation the problem is still present but now is the client that doesn't receive the answer from the server. I tried to disable the Nagle algorithm without success.
Is this problem caused by the Microsoft's socket implementation or by the joint use of NDK and MFC7?
I mean... if I'll rewrite the communication module without using NDK is possible to overtake the problem?
1. I think I do need to understand the architecture, what IO strategy are you using, blocking sockets, Asynchronous IO, CSocket is just a wrapper of winapi's of sockets, so cant say that CSocket handle all the multithreading or Asynchronous IO for you.
2. How are your classes structured (layered), there should be one main Dialog object, one CNDKserver object and multiple CNDKServerSocket objects since for each client you should have a seperate CNDKServerSockets object as far as my knowledge of blocking sockets is concerned. How the data flows between the objects?, who takes care of Network Events and how do they flow between them?
idealogically if a network event occurs
1. first CNDKServerSocket should get notified, but how for example CNDKServerSocket reads on multiple client sockets (not in a loop).
2. then the event message should be passed to CNDKServer
Object it should do the required processing on the message.
3. then the message should be passed to CChatServerDlg, which should only display it.
and thank you very very (and very) much for this code. It's working very good for us. So far we only tested the NDK within our Intranet, but we are wondering whether we could extend this to working over the internet.
My network administrator want's me to specify how he should configure the firewall.
The setup is....The server is running on my pc at work. My collegees have clients running on their pc's at work and they connect without problems....I want to have a client running at my pc at home....
Our Intranet is (of course) guarded by a firewall.
Again, thanks for your time and work, it really made a big difference.....!