Asynchronous multi-direction server-client interaction over the very same open outlet?
I have a client-server application where the customer gets on a Windows Mobile 6 tool, created in C++ and also the web server gets on complete Windows and also created in C#.
Initially, I just required it to send messages from the customer to the web server, with the web server just ever before returning a recognition that it obtained the message. Currently, I would love to upgrade it to make sure that the web server can in fact send a message to the customer to demand information. As I presently have it set up so the customer is just in receive setting after it sends out information to the web server, this does not permit the web server to send a demand any time. I would certainly need to await customer information. My first idea would certainly be to create an additional string on the customer with a different open outlet, paying attention for web server demands ... similar to the web server currently has in regard the customer. Exists a means, within the very same string and also making use of the very same outlet, to all the web server to send demands any time?
Can you make use of something to the result of
WaitForMultipleObjects() and also pass it a receive barrier and also an occasion that informs it there is information to be sent out?
Using asynchronous interaction is entirely feasible in solitary string!
There is an usual layout pattern in network software program growth called the activator pattern (look at this book). Some well well-known network collection gives an execution of this pattern (look at ACE).
Quickly, the activator is an object, you register all your sockets within, and also you await something. If something took place (new information got here, link close ...) the activator will certainly alert you. And also certainly, you can make use of just one outlet to send and also obtained information asynchronously.
Check out asio. It is a cross compatable c+npls collection for asyncronous IO. I am not exactly sure if this would certainly serve for the web server (I have actually never ever attempted to link a typical c+npls DLL to a c# task) but also for the customer it would certainly serve.
We utilize it with our application, and also it addressed a lot of our IO concurrency troubles.
When I required to write an application with a customer - web server version where the customers can leave and also enter whenever they desire, (I think that's additionally the instance for your application as you make use of smart phones) I saw to it that the customers send an on-line message to the web server, showing they were attached and also all set to do whatever they required doing.
back then the web server can send messages back to the customer trough the very same open link.
Additionally, yet I do not recognize if that applies for you, I had some type of heart beat the customers sent out to the web server, allowing it recognize it was still on-line. In this way the web server recognizes when a customer was by force separated from the network and also it can note that customer back as offline.
I'm unclear on whether you're intending to add the asynchronous little bits to the web server in C# or the customer in C+npls.
If you're speaking about doing this in C+npls, desktop computer Windows systems can do outlet I/O asynchronously via the API's that make use of overlapped I/O. For sockets, WSASend, WSARecv both permit async I/O (read the documents on their LPOVERLAPPED parameters, which you can inhabit with occasions that ready when the I/O finishes).
I do not recognize if Windows Mobile systems sustain these features, so you could need to do some added excavating.