MCPcopy Create free account
hub / github.com/Pagghiu/SaneCppLibraries / echoClient

Function echoClient

Examples/AwaitEcho/AwaitEcho.cpp:66–88  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

64}
65
66static AwaitTask echoClient(AwaitEventLoop& await, const SocketDescriptor& client, SocketIPAddress address,
67 Span<char> replyBuffer, AwaitSocketReceiveResult& reply)
68{
69 const char message[] = "niche readable await";
70
71 Result connectResult = co_await await.connect(client, address);
72 if (not connectResult)
73 {
74 co_return Result::Error("AwaitEcho client connect failed");
75 }
76 Result sendResult = co_await await.sendAll(client, {message, sizeof(message) - 1});
77 if (not sendResult)
78 {
79 co_return Result::Error("AwaitEcho client sendAll failed");
80 }
81 Result receiveResult = co_await await.receive(client, replyBuffer, reply);
82 if (not receiveResult)
83 {
84 co_return Result::Error("AwaitEcho client receive failed");
85 }
86
87 co_return Result(true);
88}
89
90static AwaitTask echoConversation(AwaitEventLoop& await, const SocketDescriptor& serverSocket,
91 const SocketDescriptor& client, SocketIPAddress address, SocketDescriptor& accepted,

Callers 1

echoConversationFunction · 0.85

Calls 5

sendAllMethod · 0.80
ErrorEnum · 0.50
ResultClass · 0.50
connectMethod · 0.45
receiveMethod · 0.45

Tested by

no test coverage detected