#include "../c++/io_peer.hpp" #include #include #include "echo.hpp" int main(){ /** * Create EventLoop * Setup EventPort to the outside world * And setup the io comms to the outside. */ auto eo_aio = saw::setup_async_io(); if(eo_aio.is_error()){ auto& err = eo_aio.get_error(); std::cerr< net_addr = nullptr; saw::own async_rmt = nullptr; std::array read_data; uint64_t read_bytes = 0; auto& network = aio.io->get_network(); network.resolve_address("127.0.0.1", 4322).then([&](auto addr){ net_addr = std::move(addr); network.connect(*net_addr).then([&](auto rmt_srv){ async_rmt = saw::heap(std::move(rmt_srv)); async_rmt->write("foo", 3); async_rmt->read(&read_data[0], 3, read_data.size()-1); async_rmt->read_done().then([&](size_t b){ for(uint64_t i = 0; i < b; ++i){ std::cout<(read_data[i]); } std::cout<on_read_disconnected().then([&](){ keep_running = false; }).detach(); }).detach(); }).detach(); wait_scope.poll(); while(keep_running){ wait_scope.wait(); } std::cout<<"Shutting down echo client"<