プロジェクトの最も重要な側面は低レイテンシであるため、必要なだけ多くの CPU を使用しても問題ないノンブロッキング ソケットから読み取る別のスレッドがあります。最初に select() を使用して読み取り可能なソケットを探すよりも、単純に read() 呼び出しをループする方が速いでしょうか?
擬似コード:
while (!finished) {
int rc = read(socket, buf);
if (rc > 0) {
// process buf
} else if (rc == 0) {
// eof, reconnect to server
} else if (errno == EGAIN) {
// nothing to do, continue
} else if (errno == ECONNREFUSED) {
// connection refused, attempt connect again
} else {
// error not yet supported
}
}