Please tell me how to make a server so that through it you can send a picture (stream) from one client to another? In principle, you can run 10 programs with different ports for 20 clients, but this is a crutch, I think. :(

one PS The arrow indicates the direction of data transfer, from whom to whom.

  • There is a client 1, which through the server sends to the client 2 a picture, which in turn receives it. It seems everything is very clear or something I do not understand, the complexity is what? - sp7
  • @ sp7 and what if there are 150 clients, the server will be confused if done in the standard way - alex-rudenkiy
  • I just do not quite understand how your customers will interact with each other. Judging by the fact that you drew from you, Client 1 will send 2 a message to client, and client 2 will only receive it and that's it. Or some other scenarios are possible, for example, each client can send a message to another? - sp7
  • @ sp7 is not, in general, an example: I have a serv on my computer, a client stands on four laptops, on any of the laptops you can make a session and then the session id will come out (for ease of connection) and wait for a computer to connect when the second computer client enters the session ID highlighted on the first laptop and presses the "ok" button, then from the first laptop there goes the drawn picture (stream) to the serv, and the serv transfers the picture to the second laptop. - alex-rudenkiy
  • And why not use RabbitMQ for your goals, are there such mechanisms as Topics and Routing in principle, can they be used in your context? - sp7

1 answer 1

In principle, you can run 10 programs with different ports for 20 clients

What for? You can use a lot of threading. Create 1 stream listener, which, when a client connects, will launch another special stream to work with it. When disabled, this thread is destroyed.

It also makes sense to work out the data transfer format so that the data is transmitted only between the "necessary" clients.

You can use ready-made solutions for ESB. Some were discussed in English SO .

In a pinch, you can try to implement your transfer format. But I deeply doubt that this will be required.

  • That's what I wanted to ask. "It also makes sense to work out the data transfer format so that the data is transmitted only between the" necessary "clients.". - alex-rudenkiy
  • @ alex-rudenkiy, unfortunately, if the problem is precisely in this it is very difficult to give a definite answer. You can use ready-made solutions for ESB, as a last resort, write your own exchange format, if the ready is not satisfied. But in the latter, I strongly doubt. - Streletz
  • And what are the solutions? - alex-rudenkiy
  • Some examples can be viewed at the link that I added to the answer. - Streletz
  • Cheto as it is difficult. And you can not just create a list from the class in which there will be: a link to the first pc, a link to the second pc and the session id. And then if the stream goes to the server then take from the class that the opposite computer lies in the list and send by the link to the required computer the received stream? - alex-rudenkiy