Click here to Skip to main content
15,885,919 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hi, i hope this is not a repeated question.
I'll show you the problem.
I've an application WPF Client, and an application WPF Server.

Sometimes, during the life of this comunication, Server should send data to Client(without client asked nothing, i know it's strange, and i don't know if it's possible).

Is possible to have a mechanism that triggers an event in the Client when in the Stream
there is the data sent by Server??

Thanks for help, i hope i have explained the problem clearly!
Posted
Comments
ZurdoDev 24-Sep-14 10:44am    
It's been a long time since I've done it but you can use sockets and essentially the client is always listening on the port that the server sends on. You can't force something from the server to the client for security reasons, your client needs to be listening and then you write code to respond. Look into .Net and sockets.
Member 11068876 24-Sep-14 11:04am    
thanks for the answer.
The problem is that i don't want that Client is always listening .
But if it is a rule, i've to change completely mechanism.
Richard MacCutchan 24-Sep-14 11:56am    
If the client is not listening then you cannot communicate with it. That's the way sockets work.
ZurdoDev 24-Sep-14 14:02pm    
1. Please reply to comments so that the user is notified.
2. Can you imagine being able to push something to the client without them listening? First, how would that even happen. Second, what a huge security risk because I could give everyone a virus without them even doing anything.
Sergey Alexandrovich Kryukov 24-Sep-14 16:01pm    
In fact I found that this question, despite some problems in formulation (why WPF?), very important. So I up-voted it and tried to answer.
—SA

1 solution

Formally speaking, pure client-server model assumes that the client is never triggered. Everything is executed by the initiative from the client side: client sends request to the server, and the server only takes the request and sends the response.

But 1) this model is so amazingly limiting that I suspect its domination is rooted in the conceptually mistaken thinking of many players in the industry; 2) it looks like you; despite of using of the term "client" and "server" in fact is looking for a way to go far away from this limiting model. And I really appreciate that you do. In fact, much more advanced models are known (such as publisher-subscriber, "server push"), but, regretfully, they were somewhat stalled, perhaps by the domination of the client-server.

So, your question raises very important issue, even the class of issues: pull technology vs. push technology:
http://en.wikipedia.org/wiki/Pull_technology[^],
http://en.wikipedia.org/wiki/Push_technology[^].

Please see my past answer: Application 'dashboard' for website accounts[^].

Further detail strongly depend on the technologies and standard you use or want to use. (And WPF it totally irrelevant here. Or, maybe you meant to mention WFC?)
If your communication layer is pretty much custom (for example, based purely on TCP), having the client part triggered would be fairly easy. Please see my past answers:
^] (anchor is broken, but the link should work; please see below),
Multple clients from same port Number[^].

(We are experiencing problem with CodeProject links in the posts. First anchor above is broken. Please use:
"http://www.codeproject.com/Answers/536542/anplusamateurplusquestionplusinplussocketplusprogr#answer2".
You have to copy and paste this URL to the browser yourself. Sorry for the inconvenience.)

—SA
 
Share this answer
 
v5
Comments
Member 11068876 25-Sep-14 3:05am    
Thank you very much, i'll see your links!
Maybe i should explain what my client-server do.
I've my pc("client") and with my mouse and my keybord i want to control another pc("server"), as if my mouse and my keyboard were connected directly to the server.

So the problem is : when i press ctrl+c , i copy for example a file, and i want to transfer that file from server to client. I need a mechanism that trigger client that there is a file in the stream opened with the server.

I Know it's a little complicated, it's only a part of a bigger application, and it's non easy explain that.
Sergey Alexandrovich Kryukov 25-Sep-14 3:09am    
This is quite possible, but there is a protocol for that: RDP. How about using it? Of course, you can make it totally custom...
—SA
Member 11068876 25-Sep-14 3:51am    
i'll try, thank you !
Sergey Alexandrovich Kryukov 25-Sep-14 9:42am    
You are very welcome.
Good luck, call again.
—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