...
This commit is contained in:
@@ -4,6 +4,21 @@
|
||||
#include "../net/adc_netproto.h"
|
||||
#include "../net/asio/adc_netservice_asio.h"
|
||||
|
||||
template <typename T>
|
||||
void receive(T& srv)
|
||||
{
|
||||
srv.asyncReceive(
|
||||
[&srv](std::error_code ec, std::string msg) {
|
||||
if (!ec) {
|
||||
std::cout << "Received: [" << msg << "]\n";
|
||||
receive(srv);
|
||||
} else {
|
||||
std::cout << "Received: " << ec.message() << "\n";
|
||||
}
|
||||
},
|
||||
std::chrono::minutes(1));
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
asio::ip::tcp::endpoint ept_s(asio::ip::tcp::v4(), 9999);
|
||||
@@ -17,10 +32,10 @@ int main()
|
||||
|
||||
adc::impl::AdcNetServiceASIOBase<asio::ip::tcp, adc::AdcStopSeqSessionProto<>> srv(ctx);
|
||||
|
||||
adc::impl::AdcNetServiceASIOBase<asio::ip::tcp, adc::AdcStopSeqSessionProto<>>::asio_async_ctx_t srv_ctx;
|
||||
srv_ctx.accept_comp_token = [](std::error_code ec) {
|
||||
// adc::impl::AdcNetServiceASIOBase<asio::ip::tcp, adc::AdcStopSeqSessionProto<>>::asio_async_ctx_t srv_ctx;
|
||||
// srv_ctx.accept_comp_token = [](std::error_code ec) {
|
||||
|
||||
};
|
||||
// };
|
||||
|
||||
// srv.asyncAccept(ept_s, srv_ctx, std::chrono::seconds(120));
|
||||
// srv.asyncConnect(ept_c, [](std::error_code ec) {
|
||||
@@ -38,13 +53,16 @@ int main()
|
||||
if (!ec) {
|
||||
std::cout << "New connection\n";
|
||||
|
||||
srv.asyncReceive(
|
||||
[](std::error_code ec, std::string msg) {
|
||||
if (!ec) {
|
||||
std::cout << "Received: [" << msg << "]\n";
|
||||
}
|
||||
},
|
||||
std::chrono::minutes(3));
|
||||
// srv.asyncReceive(
|
||||
// [](std::error_code ec, std::string msg) {
|
||||
// if (!ec) {
|
||||
// std::cout << "Received: [" << msg << "]\n";
|
||||
// } else {
|
||||
// std::cout << "Received: " << ec.message() << "\n";
|
||||
// }
|
||||
// },
|
||||
// std::chrono::minutes(1));
|
||||
receive(srv);
|
||||
} else {
|
||||
std::cout << "ACCEPT ERR: " << ec.message() << "\n";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user