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

Method bind

net/kernel_socket.cpp:715–727  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

713 using KernelSocketServer::KernelSocketServer;
714
715 int bind(const EndPoint& ep) override {
716 if (m_listen_fd >= 0)
717 LOG_ERROR_RETURN(EALREADY, -1, "already bound");
718 auto s = sockaddr_storage(ep);
719 m_listen_fd = fstack_socket(s.get_sockaddr()->sa_family, SOCK_STREAM, 0); // already non-blocking and no-delay
720 if (m_listen_fd < 0) {
721 LOG_ERRNO_RETURN(0, -1, "fail to setup DPDK listen fd");
722 }
723 int ret = fstack_bind(m_listen_fd, s.get_sockaddr(), s.get_socklen());
724 if (ret < 0)
725 LOG_ERRNO_RETURN(0, ret, "failed to bind to ", s.to_endpoint());
726 return 0;
727 }
728
729 int bind(const char* path, size_t count) override {
730 LOG_ERRNO_RETURN(ENOSYS, -1, "Not implemented");

Callers

nothing calls this directly

Calls 6

fstack_socketFunction · 0.85
fstack_bindFunction · 0.85
sockaddr_storageClass · 0.70
get_sockaddrMethod · 0.45
get_socklenMethod · 0.45
to_endpointMethod · 0.45

Tested by

no test coverage detected