MCPcopy Create free account
hub / github.com/dfranx/SHADERed / start

Method start

libs/cppdap/src/network.cpp:31–58  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

29 ~Impl() { stop(); }
30
31 bool start(int port,
32 const OnConnect& onConnect,
33 const OnError& onError) override {
34 std::unique_lock<std::mutex> lock(mutex);
35 stopWithLock();
36 socket = std::unique_ptr<dap::Socket>(
37 new dap::Socket("localhost", std::to_string(port).c_str()));
38
39 if (!socket->isOpen()) {
40 onError("Failed to open socket");
41 return false;
42 }
43
44 running = true;
45 thread = std::thread([=] {
46 do {
47 if (auto rw = socket->accept()) {
48 onConnect(rw);
49 continue;
50 }
51 if (!isRunning()) {
52 onError("Failed to accept connection");
53 }
54 } while (false);
55 });
56
57 return true;
58 }
59
60 void stop() override {
61 std::unique_lock<std::mutex> lock(mutex);

Callers 1

TESTFunction · 0.80

Calls 2

isOpenMethod · 0.45
acceptMethod · 0.45

Tested by 1

TESTFunction · 0.64