How to use a survey to receive multiple clients? (TCP server) (C)

This survey business seems like it was written crazy, and I'm not sure how to use it to allow multiple clients to connect to the server and then send their data to all other clients.

So, if I want to have three clients, I need something like:

  ufds[0].fd = sd;
  ufds[0].events = POLLIN;
  ufds[1].fd = sd2;
  ufds[1].events = POLLOUT;
  ufds[2].fd = sd2;
  ufds[2].events = POLLOUT;
  ufds[3].fd = sd2;
  ufds[3].events = POLLOUT;
  ufds[4].fd = sd2;
  ufds[4].events = POLLOUT;

And then do what exactly so that messeges can be read and written?

+4
source share
1 answer
+1

All Articles