MCPcopy Create free account
hub / github.com/Codesire-Deng/co_context / recv_session

Function recv_session

example/netcat.cpp:8–17  ·  view source on GitHub ↗

不断接收字节流并打印到stdout

Source from the content-addressed store, hash-verified

6
7// 不断接收字节流并打印到stdout
8task<> recv_session(Socket sock) {
9 alignas(8192) char buf[8192];
10 int nr = co_await sock.recv(buf);
11
12 while (nr > 0) {
13 nr = co_await (
14 lazy::write(STDOUT_FILENO, {buf, (size_t)nr}) && sock.recv(buf)
15 );
16 }
17}
18
19// 将键盘输入发送给对方
20task<> send_session(Socket sock) {

Callers 2

serverFunction · 0.70
clientFunction · 0.70

Calls 2

writeFunction · 0.85
recvMethod · 0.80

Tested by

no test coverage detected