MCPcopy Create free account
hub / github.com/boostorg/beast / main

Function main

example/websocket/client/awaitable/websocket_client_awaitable.cpp:96–137  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

94//------------------------------------------------------------------------------
95
96int
97main(int argc, char** argv)
98{
99 try
100 {
101 // Check command line arguments.
102 if(argc != 4)
103 {
104 std::cerr
105 << "Usage: websocket-client-awaitable <host> <port> <text>\n"
106 << "Example:\n"
107 << " websocket-client-awaitable echo.websocket.org 80 \"Hello, world!\"\n";
108 return EXIT_FAILURE;
109 }
110 auto const host = argv[1];
111 auto const port = argv[2];
112 auto const text = argv[3];
113
114 // The io_context is required for all I/O
115 net::io_context ioc;
116
117 // Launch the asynchronous operation
118 net::co_spawn(
119 ioc,
120 do_session(host, port, text),
121 [](std::exception_ptr e)
122 {
123 if(e)
124 std::rethrow_exception(e);
125 });
126
127 // Run the I/O service. The call will return when
128 // the socket is closed.
129 ioc.run();
130 }
131 catch(std::exception const& e)
132 {
133 std::cerr << "Error: " << e.what() << std::endl;
134 return EXIT_FAILURE;
135 }
136 return EXIT_SUCCESS;
137}
138
139#else
140

Callers

nothing calls this directly

Calls 3

whatMethod · 0.80
do_sessionFunction · 0.70
runMethod · 0.45

Tested by

no test coverage detected