| 74 | } |
| 75 | |
| 76 | int server(actor_system& sys, uint16_t port) { |
| 77 | auto src = sys.spawn(producer); |
| 78 | auto actual_port = sys.middleman().publish(src, port); |
| 79 | if (!actual_port) { |
| 80 | std::cout << "failed to open port " << port << ": " |
| 81 | << to_string(actual_port.error()) << '\n'; |
| 82 | return EXIT_FAILURE; |
| 83 | } |
| 84 | while (!shutdown_flag) |
| 85 | std::this_thread::sleep_for(250ms); |
| 86 | anon_send_exit(src, exit_reason::user_shutdown); |
| 87 | return EXIT_SUCCESS; |
| 88 | } |
| 89 | |
| 90 | int client(actor_system& sys, const std::string& host, uint16_t port) { |
| 91 | auto attempt = 0; |