MCPcopy Create free account
hub / github.com/Codeya-IDE/deepin-ide / start

Method start

3rdparty/cppdap/src/network.cpp:32–62  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

30 ~Impl() { stop(); }
31
32 bool start(int port,
33 const OnConnect& onConnect,
34 const OnError& onError) override {
35 std::unique_lock<std::mutex> lock(mutex);
36 stopWithLock();
37 // modified by ZhangTingAn:‘localhost‘ -> ‘0.0.0.0‘ receive network connections from other machines
38 // used to remote debug
39 socket = std::unique_ptr<dap::Socket>(
40 new dap::Socket("0.0.0.0", std::to_string(port).c_str()));
41
42 if (!socket->isOpen()) {
43 onError("Failed to open socket");
44 return false;
45 }
46
47 stopped = false;
48 thread = std::thread([=] {
49 while (true) {
50 if (auto rw = socket->accept()) {
51 onConnect(rw);
52 continue;
53 }
54 if (!stopped) {
55 onError("Failed to accept connection");
56 }
57 break;
58 };
59 });
60
61 return true;
62 }
63
64 void stop() override {
65 std::unique_lock<std::mutex> lock(mutex);

Callers 1

TESTFunction · 0.45

Calls 4

to_stringFunction · 0.85
c_strMethod · 0.80
isOpenMethod · 0.45
acceptMethod · 0.45

Tested by 1

TESTFunction · 0.36