MCPcopy Create free account
hub / github.com/3rdparty/libprocess / setup_server

Method setup_server

include/process/ssl/gtest.hpp:292–323  ·  view source on GitHub ↗

* Initializes a listening server. * * @param environment The SSL environment variables to launch the * server socket with. * * @return Socket if successful otherwise an Error. */

Source from the content-addressed store, hash-verified

290 * @return Socket if successful otherwise an Error.
291 */
292 Try<process::network::inet::Socket> setup_server(
293 const std::map<std::string, std::string>& environment)
294 {
295 set_environment_variables(environment);
296
297 const Try<process::network::inet::Socket> create =
298 process::network::inet::Socket::create(
299 process::network::internal::SocketImpl::Kind::SSL);
300
301 if (create.isError()) {
302 return Error(create.error());
303 }
304
305 process::network::inet::Socket server = create.get();
306
307 // We need to explicitly bind to the address advertised by libprocess so the
308 // certificate we create in this test fixture can be verified.
309 Try<process::network::inet::Address> bind =
310 server.bind(
311 process::network::inet::Address(net::IP(process::address().ip), 0));
312
313 if (bind.isError()) {
314 return Error(bind.error());
315 }
316
317 const Try<Nothing> listen = server.listen(BACKLOG);
318 if (listen.isError()) {
319 return Error(listen.error());
320 }
321
322 return server;
323 }
324
325 /**
326 * Launches a test SSL client as a subprocess connecting to the

Callers

nothing calls this directly

Calls 5

AddressClass · 0.85
addressFunction · 0.50
getMethod · 0.45
bindMethod · 0.45
listenMethod · 0.45

Tested by

no test coverage detected