V
V
Vitaly Pukhov2015-04-03 08:03:45
Programming
Vitaly Pukhov, 2015-04-03 08:03:45

How to create a client-server in C# with "Alive" connection?

It is necessary to write a client-server with the support of "live" sessions, that is, something like this architecture:
Server:

  • Must be a lot of threading
  • Must accept and not close connections from clients
  • A separate thread on the server should be able to "enumerate" connected clients and send an arbitrary byte[] to any of them without closing the connection afterwards
  • Must accept byte[] from clients and be able to determine from which client a message is received
Customer:
  • Must connect to the server and not close the connection
  • Must be able to send a byte[] message to the server and receive messages from it on the same connection

I tried to implement it with udp sockets and remoting, it works and is fast enough, but it turned out to be a gigantic crutch, I don’t like this solution purely aesthetically.
All examples with tcp sockets are suitable for temporary connections that are closed immediately after transmission and are not suitable for holding sessions and constant communication. What would be the best way to implement something like this?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Ryzhov, 2015-04-15
@RyzhovAlexandr

There is also an alternative to WCF duplex, but it has a number of features that need to be taken into account:
1. To use via http, it requires the creation of a separate reverse channel, so it is better to use net.tcp
2. To maintain open reverse channels, you must manually implement ping It's a
shame that for such a seemingly typical task Microsoft did not give a convenient mechanism out of the box, wcf but still you have to tweak and bring to mind

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question