MCPcopy Create free account
hub / github.com/alibaba/PhotonLibOS / bind

Method bind

net/kernel_socket.cpp:315–328  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

313 }
314
315 int bind(const EndPoint& ep) override {
316 auto s = sockaddr_storage(ep);
317 if (m_listen_fd < 0) {
318 m_listen_fd = socket(s.get_sockaddr()->sa_family, 0, m_nonblocking, true);
319 if (m_listen_fd < 0) return -1;
320 }
321 if (m_opts.setsockopt(m_listen_fd) != 0) {
322 return -1;
323 }
324 int ret = ::bind(m_listen_fd, s.get_sockaddr(), s.get_socklen());
325 if (ret < 0)
326 LOG_ERRNO_RETURN(0, ret, "failed to bind to ", s.to_endpoint());
327 return 0;
328 }
329
330 int bind(const char* path, size_t count) override {
331 if (m_autoremove && is_socket(path)) {

Callers

nothing calls this directly

Calls 9

unlinkFunction · 0.85
fill_uds_pathFunction · 0.85
sockaddr_storageClass · 0.70
socketFunction · 0.70
ALogStringClass · 0.50
get_sockaddrMethod · 0.45
setsockoptMethod · 0.45
get_socklenMethod · 0.45
to_endpointMethod · 0.45

Tested by

no test coverage detected