The client application in C ++ transmits data to the HTTP server - client ID (to indicate presence), webcam frames (on request), desktop screenshots (on request). If it would be possible to broadcast either a camera or a display, then the question would not be, but the task should be the possibility of simultaneous broadcasting.

Through a client socket, the client broadcasts its ID with information about whether it can use the camera (not everyone has it). When a server responds with a request to broadcast a camera, desktop, or all, the client creates a separate stream for the camera and a separate stream for the desktop, because the frame broadcast intervals are different (if you can send a frame from a camera to 6 kb 20-25 times a second, KB display no more than 2, so that the network does not overload).

And here I have a creative dead end because of the possible incomplete understanding of the operation of sockets: Is it possible to use one socket for these threads? The data volumes are decent, they will not interfere with each other on the same socket with Content-Transfer-Encoding: binary ?

  • And what do you think? :) - Pavel Mayorov
  • I suspect that you will have to do separate sockets, but may still not be necessary? :) Maybe I don’t know everything about sockets, so I ask for hints ... :)) - Iceman
  • one
    If correctly and neatly something can be. Moreover, they even do that. The main thing is to synchronize everything, so that it does not mix. And on the server side, you will need to do the reverse procedure - decompose the stream into two. - KoVadim
  • One more detail - in each stream the headers will be different. For the server, there is no problem with headers scattering data into their parts of the allocated memory. The main thing for me is that the client sends everything correctly and does not interfere with the data. If a frame from the camera and from the desktop comes through the socket at the same time, isn’t it possible that one mixed binary comes onto the server? - Iceman
  • @KoVadim got the idea, but what if you write a socket class, and then create a class using multiple stream class inheritance and a socket class. what happens? ) - perfect

2 answers 2

I didn’t quite understand what was meant by separate threads on the client, if the stream is a separate connection to the server, then you should actually have a socket per connection / stream, well, if all the data goes through the same channel, then you need 1 socket that is, you need to build on the client's architecture, but there is no other choice. In any case, you will have one master socket waiting for the connection, which will create new slave sockets for each connection. If it is possible to create a socket on the "stream", then it is better to do so, select / epoll, etc. to help. The average PC is able to work with tens of thousands of sockets at the same time, quietly reading / sending gigabits / sec.

sitev_ru - something you do not understand at all, how many simultaneous requests can be sent by "saytik" depends on the browser, by default in modern browsers it is 6-8 simultaneous requests for HTTP / 1.1.

  • Thanks for the tip - Iceman

A C ++ client application is a socket client, and an HTTP server is a socket server. It’s ok if multiple clients cling to the same server ...

Answer: many socket clients and one socket server

PS The average site can send to the HTTP server up to several dozen or even hundreds of requests at the same time. These are all sorts of pictures, js scripts, etc.