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

Class Socket

include/process/socket.hpp:252–455  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

250 */
251template <typename AddressType>
252class Socket
253{
254public:
255 static_assert(
256 std::is_convertible<AddressType, network::Address>::value,
257 "Requires type convertible to `network::Address`");
258
259 /**
260 * Returns an instance of a `Socket` using the specified kind of
261 * implementation.
262 *
263 * @param s Optional. The file descriptor to wrap with the `Socket`.
264 * @param kind Optional. The desired `Socket` implementation.
265 *
266 * @return An instance of a `Socket`.
267 */
268 static Try<Socket> create(
269 int_fd s,
270 SocketImpl::Kind kind = SocketImpl::DEFAULT_KIND())
271 {
272 Try<std::shared_ptr<SocketImpl>> impl = SocketImpl::create(s, kind);
273 if (impl.isError()) {
274 return Error(impl.error());
275 }
276 return Socket(impl.get());
277 }
278
279 /**
280 * Returns an instance of a `Socket` using `AddressType` to determine
281 * the address family to use. An optional implementation kind can be
282 * specified. The NONBLOCK and CLOEXEC options will be set on the
283 * underlying file descriptor for the socket.
284 *
285 * @param kind Optional. The desired `Socket` implementation.
286 *
287 * @return An instance of a `Socket`.
288 */
289 // TODO(josephw): MESOS-5729: Consider making the CLOEXEC option
290 // configurable by the caller of the interface.
291 static Try<Socket> create(SocketImpl::Kind kind = SocketImpl::DEFAULT_KIND());
292
293 /**
294 * Returns an instance of a `Socket` using the specified
295 * `Address::Family` to determine the address family to use. An
296 * optional implementation kind can be specified. The NONBLOCK and
297 * CLOEXEC options will be set on the underlying file descriptor for
298 * the socket.
299 *
300 * NOTE: this is only defined for `AddressType` of
301 * `network::Address`, all others are explicitly deleted.
302 *
303 * @param kind Optional. The desired `Socket` implementation.
304 *
305 * @return An instance of a `Socket`.
306 */
307 static Try<Socket> create(
308 Address::Family family,
309 SocketImpl::Kind kind = SocketImpl::DEFAULT_KIND());

Callers 6

TEST_FFunction · 0.85
TEST_PFunction · 0.85
foreachFunction · 0.85
createMethod · 0.85
acceptMethod · 0.85
createMethod · 0.85

Calls 1

getMethod · 0.45

Tested by 3

TEST_FFunction · 0.68
TEST_PFunction · 0.68
foreachFunction · 0.68