design for socket server and client as a service
- From: Jonathan <blank@xxxxxxxxxxx>
- Date: Thu, 03 Dec 2009 23:14:09 +0000
Hello everyone,
I could really do with your help with some design decisions on this; none of my peers has C# experience and I lurch from frustration to Eureka moments learning it alone!
I won't ramble on in order to keep this concise
scenario:
====================
I am developing a windows service to accept incoming messages from one server, transform them and send to another server via sockets.
Biztalk et al are not an option for me.
I have a number of constraints that i need to work around:
o The destination server is available on a schedule so i need to take care of downtime
o the destination server is liable to be taken down on an ad-hoc basis so disconnects and reconnects need to be handled
o The source server makes a connection and maintains this indefinitely for subsequent messages as long as there is activity...
o the source server will only maintain its connection for a limited time idle (several hours but not indefinitely)
o the source server requires acknowledgement (ACK/NACK) of acceptance of a message before sending subsequent messages
o the destination server provides no acknowledgement of message receipt
In analysing the requirements I have come up with the following candidate objects:
Service controller (instantiated by the ServiceBase subclass)
==============================================================
Start()
Stop()
methods which set an instance variable to indicate whether the service should stop
A method which is invoked on a thread to contain all logic for message handling.
ClientSocket class
=========================
contains plumbing code for client socket and methods to send outgoing messages
method to determine whether the client is available...
ServerSocket class
========================
contains plumbing code for server socket and methods to acquire incoming messages
This isn't complete but captures the essence, I feel.
I am, however, struggling with the logic to manage this; particularly the exceptional conditions which may occur within the main thread loop...
For instance, either end of the connection may drop at any point, the client end may or may not be available and I need to wait until it is, I may need to reset and reconnect either end should they be down, and all within the confines of the while-loop which continues as long as the service is up.
I just can't help thinking that I am missing some part of the puzzle - maybe I am not constrained to do everything in the same threaded method and I could implement a Timer callback outside the thread with no consequential effects.
Is anyone able to suggest the skeleton of a robust design or point me at a suitable resource?
I am conscious that this has turned into something less than concise but, not knowing the answers makes it difficult to ask the right questions.
Here's hoping you you might provide me with another Eureka moment.
Regards
Jon
.
- Prev by Date: Anybody integrate ASP.NET Membership with Facebook Connect etc.
- Next by Date: Connect to mailbox on an Exchange server
- Previous by thread: Anybody integrate ASP.NET Membership with Facebook Connect etc.
- Next by thread: Connect to mailbox on an Exchange server
- Index(es):
Relevant Pages
|