MCPcopy Create free account
hub / github.com/dermesser/libsocket / main

Function main

examples++/unix_server_stream.cpp:14–45  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

12// message.
13
14int main(void) {
15 using libsocket::unix_stream_client;
16 using libsocket::unix_stream_server;
17 using std::string;
18
19 string bindpath = "/tmp/unixsocket";
20 char* answer = new char[128];
21
22 memset(answer, 0, 128);
23
24 try {
25 unix_stream_server srv(bindpath);
26
27 unique_ptr<unix_stream_client> client;
28 client = srv.accept2();
29
30 client->rcv(answer, 127);
31 // Alternatively:
32 // string xyz;
33 // xyz.resize(127);
34 //*client >> xyz;
35
36 std::cout << answer;
37
38 *client << "Hello back from server!\n";
39
40 } catch (const libsocket::socket_exception& exc) {
41 std::cerr << exc.mesg;
42 }
43
44 return 0;
45}

Callers

nothing calls this directly

Calls 2

accept2Method · 0.45
rcvMethod · 0.45

Tested by

no test coverage detected