Click here to Skip to main content
15,896,912 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello i need a server and client application which server application triggers client application to download xml file to make updates.
Posted
Updated 7-Jul-11 14:07pm
v2

In a pure client-server paradigm there is no a way to trigger a client to do something. A client is purely active, a server is purely passive, it only responds to request sent by a client.

To trigger a client you need to… stop calling the sides "client" and "server" :-).

Seriously, you will need inversion of control (http://en.wikipedia.org/wiki/Inversion_of_control[^]). The concept close to what you need is publisher-subscriber. A client part should connect to the service and subscribe to some class of events. A server should update its collection of clients (for example, represented by their remote sockets, in the simplest case). When some events happens in the service process, it should send notification to all the clients in the collection.

As a minimum, servicing of the publisher-subscriber requires two threads on the service part: one to listen to new connections, one to perform data exchange via network stream using some application-level protocol.

This schema can be (and usually should) be combined with "regular" client-server interaction.

Please see my skeleton of the architecture of such application: Multple clients from same port Number[^]. There can be different designs implementing such behavior. I tried to describe nearly the simplest possible case.

I fear to say, such work in not quite for beginners.

—SA
 
Share this answer
 
v2
Comments
fjdiewornncalwe 7-Jul-11 20:33pm    
Great Explanation
Sergey Alexandrovich Kryukov 7-Jul-11 20:34pm    
Wow! Thank you, Kramer. How could you be so quick? :-).
--SA
Christian Graus 7-Jul-11 20:34pm    
Good explanation, but I feel sure you wasted your time in terms of the OP being able to do anything with it.
Sergey Alexandrovich Kryukov 7-Jul-11 20:37pm    
Again, most likely you're perfectly right. But every inquirer deserve a chance. May be it will inspire OP to think about it, get good experience and get back to such tasks when ready and comfortable with threading and networking.
--SA
Espen Harlinn 7-Jul-11 20:39pm    
I think he'll manage, my 5 by the way :)
A really easy solution is to use Msmq - here is an article I wrote a while ago: Microsoft Message Queuing – A Simple Multithreaded Client and Server[^]

Just create a queue on the client side too, and pass the name to the server. Add an OnReceiveCompleted handler to the client similar to what I do for the server - actually the client logic will be fairly identical to the server logic.

This approach is nice and simple - give it an hour or two, and you are done.

Best regards
Espen Harlinn
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 7-Jul-11 20:43pm    
Great, this is you work. But it's called "Client and Server" which does not imply having inversion of control (service part triggering "client", in this case). Please see my solution to understand what I mean.

I'll try to look at your article later, but for now will you just tell me: is that possibility available, and what's the main idea?

Thank you.
--SA
Espen Harlinn 7-Jul-11 21:07pm    
Both client and server will be implmented in a manner similar to my server implmentation. The point is that both of them will be able to initiate an exchange of information. The only difference being that the "client" will have to tell the "server" where it's supposed to send notifications - i.e. pass the queue name to the server.
thatraja 8-Jul-11 23:56pm    
Great article by you. 5!
Espen Harlinn 9-Jul-11 6:20am    
Thank you, thatraja :-)
OK, well, that sounds trivial. Have you started yet ? If you're not a programmer, you need to pay a programmer to do this, not ask us to do it for you.
 
Share this answer
 
Comments
deniz_ 7-Jul-11 20:15pm    
actually i am a student i dont want whole program any help will be appreciated
Sergey Alexandrovich Kryukov 7-Jul-11 20:40pm    
By the way, may I give you another advice: never use the fact of being a student or a beginner for any kind of excuses -- it will never help you. Also, you can create a negative impression in people who did great things during their student's years. Do you know such people?
--SA
Sergey Alexandrovich Kryukov 7-Jul-11 20:32pm    
You're write of course, but can it be explained conceptually?
Please see my solution.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900