Click here to Skip to main content
15,744,304 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
I have .NET Remoting server and client application based on events raising from server to send data to clients.......... when some client disconnected due to LAN connection or due to some other reason, how it is possible to for server application to remove registered event from its invocation list.
Posted
Comments
Sergey Alexandrovich Kryukov 12-Dec-11 1:35am    
What is the event you register? Do you use threading?
--SA

check this codeproject link
How to stop a service using .NET Remoting[^]
--NDK
 
Share this answer
 
This problem is solved very elegantly, but the whole problem looks different, because the design I would advise is not based on events. Basically, you make applications multi-threading; and the service needs two threads; one for listening for new connections, one reading/writing from/to a network stream. The idea is to use exception-driven handle of disconnections, which excludes the need in graceful disconnections (which is impossible to guarantee anyway, because disconnection can be also accidental). The exception handler looks at the handle representing the remote client sockets and removes it from the container holding such offending client socket.

For some more detail, please see my past solution for this problem: using api in c# and socketprogramming[^].

—SA
 
Share this answer
 

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