I have a server, I wrote it in C #, and the clients, they send all sorts of messages over TCP / IP. Well, I need to come up with something or suggest how to do it right. It is necessary that the request be sent from the server to the client, I know what it is impossible to do, the reason is that, every second or 10 seconds, it is not comfy terebonkat server, take into account the fact that users can reach up to 20-30 at a time. Is it possible to find some alternative?

  • five
    TCP allows you to send data in both directions. - Pavel Mayorov
  • So customers must wait for the connection, and not send requests? And the server in turn to poll them? Or is the server in standby waiting for a connection, but at some point the survey itself begins? - DartAlex

1 answer 1

Too little specifics in the question, but if you do not take this into account for the implementation of the client server notification mechanism, the following options come to mind:

  1. Wcf duplex services is a situation in which both the client and the server are both Service Consumer and Service Provider , i.e. speaking in simple words, the server has the opportunity to call methods on the client side.

  2. Using queues, for example of the same RabbitMq ( Publish/Subscribe mode, in fact this mode is a publisher-subscriber pattern), the point is that the client subscribes to certain information (event). What could it be? Yes, anything, for example, we may be interested in any exceptions that occur during the operation of the server side of the application. In this case, when an exception occurs, we (the server) perform Publish and notify all clients who subscribe to this event of its occurrence.

I will add that all these mechanisms work out of the box, i.e. To wisely and invent some crutches and bicycles is not necessary) So look, maybe something from the proposed will suit you.