Skip to content
Snippets Groups Projects

[EchoServers] improve the callback based echoserver

Merged Florian Fischer requested to merge aj46ezos/emper:improve-echoservers into master
2 files
+ 48
40
Compare changes
  • Side-by-side
  • Inline
Files
2
+ 3
1
@@ -27,6 +27,8 @@ static const std::string HOST = "::";
static const std::string PORT = "12345";
static const int BACKLOG = 1024;
static const size_t BUF_SIZE = 1024;
static unsigned int computations_us = 0;
static unsigned int max_computations_us = 0;
static float max_computations_probability = -1;
@@ -98,7 +100,7 @@ auto main(int argc, char* argv[]) -> int {
auto serverFunc = [](int socket) {
// NOLINTNEXTLINE(modernize-avoid-c-arrays)
char buf[1024];
char buf[BUF_SIZE];
while (!quit.load(std::memory_order_consume)) {
ssize_t bytes_recv = emper::io::recvAndWait(socket, buf, sizeof(buf), 0);
if (unlikely(bytes_recv <= 0)) {
Loading