質問

Here is my simplified scenario, every Client its a PC on a LAN:


Client 1:

Add the maximum number: _
Maximum number: 0

Client 2:

Add the maximum number:
Maximum number: 0

So Client 1 saves "1" as the maximum number and Client 2 should automatically recieve the update and change to:


Client 2:

Add the maximum number: _
Maximum number: 1 (last updated by Client 1 on 23/04/2014 at 19:16) 

Whats the best aproach to achieve this using c# winforms and sql sever 2012 (for saving the numbers).

役に立ちましたか?

解決

There are many methods:

1-Polling: each user asks to the db server in regular intervals for update

    Pros: very easy to implement, secure
    Cons: consumes too much bandwith and db server process

2-Centralized TCP server: a dedicated machine listens for connections, each client connects to it and notifies events, the server redirects those events to corresponding clients.

    Pros: minimum bandwith, not much process required
    Cons: more complex to program, need a machine to act as server

3-Decentralized UDP notifications: if the clients are in the same LAN, then you can broadcast UDP packets in that network, in this way each client will receive every notification sent by any client.

    Pros: minimum bandwith, 0 process required, no need for central server
    Cons: it's not guaranteed a packet arrives it's destination (but in a close LAN usually they do).

So, those are the most common ways to do it, now you must balance your requirements and choose one.

In your case, I would try the UDP way, if you need to ensure the reception of the packet then your clients can wait for a response from the target of an event and if in X time they don't receive the response then broadcast the packet again, in this way you will ensure reception.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top