#include "../c++/io.hpp" #include #include #include "echo.hpp" std::string message_content = "Hey there! Sending this message"; 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(saw::echo_address, saw::echo_port).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(&message_content[0], message_content.size()); async_rmt->read(&read_data[0], message_content.size(), read_data.size()-1); async_rmt->read_done().then([&](size_t b){ std::cout<<"Received bytes:\n"; for(uint64_t i = 0; i < b; ++i){ std::cout<(read_data[i]); } std::cout<<'\n'<on_read_disconnected().then([&](){ keep_running = false; std::cout<<"Disconnected"<