#include "local.h" #include "utils.h" using namespace std; // To store client's socket list list clients_list; // for debug mode int DEBUG_MODE = 0; int main(int argc, char *argv[]) { // *** Define debug mode // any additional parameres on startup // i.e. like './server f' or './server debug' // we will switch to switch to debug mode(very simple anmd useful) if(argc > 1) DEBUG_MODE = 1; if(DEBUG_MODE){ printf("Debug mode is ON!\n"); printf("MAIN: argc = %d\n", argc); for(int i=0; i::iterator it; for(it = clients_list.begin(); it != clients_list.end(); it++){ if(*it != client){ // ... except youself of course CHK(send(*it, message, BUF_SIZE, 0)); if(DEBUG_MODE) printf("Message '%s' send to client with fd(%d) \n", message, *it); } } if(DEBUG_MODE) printf("Client(%d) received message successfully:'%s', a total of %d bytes data...\n", client, buf, len); } return len; }