in code of chat room. use "while(true)" keep receive message, way waste cpu.how can improve code? have no idea it.
(this part of code)
void* cooloiclientsocket::recv_t(void* arg) { std::string message; cooloisocket* serversocket = static_cast<cooloisocket*>(arg); //cooloiclientsocket *p = new cooloiclientsocket; while(true) { if(recv(*serversocket,message)) { std::cout << message << std::endl; } else break; sleep(1); } }
Comments
Post a Comment