Answer the question
In order to leave comments, you need to log in
How to remove freezes on the server using select?
I wrote a proxy server. The server is single-threaded, it works through select. I have a piece of code that blocks the server:
bool closeConnect = false;
std::string req = _getReq(closeConnect, fd);
try {
_dbSock->init();
_dbSock->connectTo();
} catch (std::exception &e) {
std::cerr << "DB sock: " << e.what() << std::endl;
closeConnect = true;
}
if (!closeConnect) {
send(_dbSock->getSocket(), req.c_str(), req.size(), 0);
bool tmp;
req.erase();
req = _getReq(tmp, _dbSock->getSocket());
std::cerr << req.size();
send(fd, req.c_str(), req.length(), 0);
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question