0
votes

i'm having some sync trouble with threads and sockets. I need one thread to recive incoming connections on socket (and remember client data to respond) and other thread to setup frames and send current frame to listed clients. So i was wondering if its possible to (kinda) put my data frames into server socket, so that everyone could just read current frame from socket without server knowing.

Server will just spam its socket with some data and client will get data without server actions. Is this possible? how?

I'm currently doing it pretty messed up way which i dont like:

  • server is listening on one thread for incoming transmissions and upon reciving such, add client data to list.
  • on other thread server is sending data to all clients from list.

EDIT:

I want to send data to some kind of buffer from which clients are allowed to read. (client doesnt have to read all messages server sends, just the one buffer contains at the moment of clients request), i dont want server to even notice that clients are reading from buffer if possible.

Right now threads are syncronised using uniqe_lock

1
Your question is hard to read: are you trying to transmit the same data to multiple clients, and would like to send it once for all, instead of repeatedly for each? - ams
Could you provide a mvce ? - Richard Dally
Before thinking in term of sockets, please describe what you want. What I have understood until now is that: 1. client connect to server, and says it wants data 2. server prepares a frame for that client 3. client comes back to read its own data. What I could not guess: how are client identified (are they?) by IP? by an id? Do they read their own data or all data or last data (same for all clients). It should not be hard to design... once we know what is expected! - Serge Ballesta

1 Answers

0
votes

What you're describing is probably MultiCast. Specifically, IP MultiCast (I think).

Searching finds a number of useful resources. This one looks concise, and includes coded examples (although I'm not sure how current it is).

If you're only transmitting to a LAN then broadcast will work too.