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

Function main

examples++/client.cpp:16–42  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14 */
15
16int main(void) {
17 using std::string;
18
19 using libsocket::inet_stream;
20
21 string host = "::1";
22 string port = "1235";
23 string answer;
24
25 answer.resize(32);
26
27 try {
28 libsocket::inet_stream sock(host, port, LIBSOCKET_IPv6);
29
30 sock >> answer;
31
32 std::cout << answer;
33
34 sock << "Hello back!\n";
35
36 // sock is closed here automatically!
37 } catch (const libsocket::socket_exception& exc) {
38 std::cerr << exc.mesg;
39 }
40
41 return 0;
42}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected