MCPcopy Create free account
hub / github.com/caozhiyi/CppNet / main

Function main

test/echo/EchoClient.cpp:52–83  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

50}
51
52int main() {
53
54 cppnet::CCppNet net;
55 net.Init(1);
56
57 net.SetConnectionCallback(ConnectFunc);
58 net.SetWriteCallback(WriteFunc);
59 net.SetReadCallback(ReadFunc);
60 net.SetDisconnectionCallback(DisConnectionFunc);
61 for (size_t i = 0; i < 10000; i++) {
62#ifndef __linux__
63 std::string msg = GetMsg();
64 net.Connection("127.0.0.1", 8921, msg.c_str(), msg.length());
65#else
66 net.Connection("127.0.0.1", 8921);
67#endif // !__linux__
68 }
69
70 // wait all connect success.
71 base::CRunnable::Sleep(5000);
72
73 while (1) {
74 // sleep 1s;
75 for (auto iter = handle_vec.begin(); iter != handle_vec.end(); ++iter) {
76 base::CRunnable::Sleep(1);
77 std::string msg = GetMsg();
78 (*iter)->Write(msg.c_str(), msg.length());
79 }
80 }
81
82 net.Join();
83}

Callers

nothing calls this directly

Calls 9

GetMsgFunction · 0.70
InitMethod · 0.45
SetConnectionCallbackMethod · 0.45
SetWriteCallbackMethod · 0.45
SetReadCallbackMethod · 0.45
ConnectionMethod · 0.45
WriteMethod · 0.45
JoinMethod · 0.45

Tested by

no test coverage detected