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

Function send_session

example/netcat.cpp:20–29  ·  view source on GitHub ↗

将键盘输入发送给对方

Source from the content-addressed store, hash-verified

18
19// 将键盘输入发送给对方
20task<> send_session(Socket sock) {
21 alignas(8192) char buf[8192];
22 int nr = co_await lazy::read(STDIN_FILENO, buf);
23
24 while (nr > 0) {
25 nr = co_await (
26 sock.send({buf, (size_t)nr}) && lazy::read(STDIN_FILENO, buf)
27 );
28 }
29}
30
31task<> server(uint16_t port) {
32 acceptor ac{inet_address{port}};

Callers 2

serverFunction · 0.70
clientFunction · 0.70

Calls 2

readFunction · 0.85
sendMethod · 0.80

Tested by

no test coverage detected