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

Function transfer

example/cpp20/channels/throttling_proxy.cpp:44–61  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

42}
43
44awaitable<void> transfer(tcp::socket& from,
45 tcp::socket& to, token_channel& tokens)
46{
47 std::array<unsigned char, 4096> data;
48 for (;;)
49 {
50 std::size_t bytes_available = co_await tokens.async_receive();
51 while (bytes_available > 0)
52 {
53 std::size_t n = co_await from.async_read_some(
54 buffer(data, bytes_available));
55
56 co_await async_write(to, buffer(data, n));
57
58 bytes_available -= n;
59 }
60 }
61}
62
63awaitable<void> proxy(tcp::socket client, tcp::endpoint target)
64{

Callers 1

proxyFunction · 0.85

Calls 4

bufferFunction · 0.85
async_writeFunction · 0.85
async_receiveMethod · 0.45
async_read_someMethod · 0.45

Tested by

no test coverage detected