MCPcopy Create free account
hub / github.com/boostorg/asio / main

Function main

example/cpp20/channels/throttling_proxy.cpp:103–132  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

101}
102
103int main(int argc, char* argv[])
104{
105 try
106 {
107 if (argc != 5)
108 {
109 std::cerr << "Usage: throttling_proxy";
110 std::cerr << " <listen_address> <listen_port>";
111 std::cerr << " <target_address> <target_port>\n";
112 return 1;
113 }
114
115 io_context ctx;
116
117 auto listen_endpoint =
118 *tcp::resolver(ctx).resolve(argv[1], argv[2],
119 tcp::resolver::passive).begin();
120
121 auto target_endpoint =
122 *tcp::resolver(ctx).resolve(argv[3], argv[4]).begin();
123
124 tcp::acceptor acceptor(ctx, listen_endpoint);
125 co_spawn(ctx, listen(acceptor, target_endpoint), detached);
126 ctx.run();
127 }
128 catch (std::exception& e)
129 {
130 std::cerr << "Exception: " << e.what() << "\n";
131 }
132}

Callers

nothing calls this directly

Calls 5

listenFunction · 0.70
co_spawnFunction · 0.50
beginMethod · 0.45
resolveMethod · 0.45
runMethod · 0.45

Tested by

no test coverage detected