Facebook
From Chunky Eider, 2 Weeks ago, written in C++.
Embed
Download Paste or View Raw
Hits: 64
  1. void sendMetadata(){
  2.     for (int m: meta){
  3.             struct timeval timeout;
  4.     timeout.tv_sec = 1;
  5.     timeout.tv_usec = 0;
  6.  
  7.     if (setsockopt (metadata, SOL_SOCKET, SO_RCVTIMEO, (char *)&timeout,
  8.                 sizeof(timeout)) < 0)
  9.         perror("setsockopt failed\n");
  10.  
  11.     if (setsockopt (metadata, SOL_SOCKET, SO_SNDTIMEO, (char *)&timeout,
  12.                 sizeof(timeout)) < 0)
  13.         perror("setsockopt failed\n");
  14.         if (m != metadata){
  15.             for (Client *c : clients){
  16.                 for (Room r : c->rooms){
  17.                     string row = to_string(r.desc) + ":" + r.name + ":" + c->Name;
  18.                     row.append("\n");
  19.                     sendMessage(m,row);
  20.                 }
  21.             }
  22.             sendMessage(m,delimeterMetaDate);
  23.         }
  24.     }
  25. }