MCPcopy Create free account
hub / github.com/apache/mesos / getFreePort

Function getFreePort

src/tests/utils.cpp:74–93  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

72
73
74Try<uint16_t> getFreePort()
75{
76 // Bind to port=0 to obtain a random unused port.
77 Try<inet::Socket> socket = inet::Socket::create();
78
79 if (socket.isError()) {
80 return Error(socket.error());
81 }
82
83 Try<inet::Address> address = socket->bind(inet4::Address::ANY_ANY());
84
85 if (address.isError()) {
86 return Error(address.error());
87 }
88
89 return address->port;
90
91 // No explicit cleanup of `socket` as we rely on the implementation
92 // of `Socket` to close the socket on destruction.
93}
94
95
96string getModulePath(const string& name)

Callers 4

TEST_FFunction · 0.85
TEST_FFunction · 0.85

Calls 5

errorMethod · 0.65
createFunction · 0.50
ErrorFunction · 0.50
isErrorMethod · 0.45
bindMethod · 0.45

Tested by

no test coverage detected