design for socket server and client as a service

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



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
.



Relevant Pages

  • Re: suid bit files + securing FreeBSD (new program: LockDown)
    ... I found the design maybe LockDown or your IDS could use ... So you need at least one CFC server, ... the client boots, it will just use the files it already have and update ... The multicast address the client is a member of. ...
    (FreeBSD-Security)
  • Re: VB connection to SQL server
    ... > the client machine begins to lose its relevance and accuracy as soon as it ... > aware that the data is probably out of date, a client sided cursor might ... > design minimises the possibility that records will have changed in the ... >> The Database server is in the office, and people use the Vb program from ...
    (microsoft.public.vb.database)
  • Re: Distributed applications and OOD
    ... On the server-side, client ... > still it is the only working design for distributed applications. ... implementing an OOA model in an EJB/J2EE environment, ... in the client, in the DB, or in the server. ...
    (comp.object)
  • Re: Architectural feedback
    ... That can influence your design. ... bank branches absolutely must be able to function with a failed server (or ... This means a lot of functionality is duplicated on the ... > with WinForms-based apps (assume all client machines are Windows running ...
    (microsoft.public.dotnet.general)
  • Re: What doesnt lend itself to OO?
    ... >> proxy and instructs the server to constuct the real object. ... rather than client code. ... If 'clock' is instantiated in the server, ... > for the server interface at the OOA level. ...
    (comp.object)