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

Function socket

net/kernel_socket.cpp:66–79  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

64namespace net {
65
66static int socket(int family, int protocol = 0,
67 bool nonblocking = true, bool nodelay = true) {
68 int fd = ::socket(family, SOCK_STREAM, protocol);
69 if (fd < 0)
70 LOG_ERRNO_RETURN(0, -1, "failed to create socket fd");
71 if (nonblocking)
72 set_fd_nonblocking(fd);
73 if (nodelay) {
74 int v = 1;
75 if (::setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &v, sizeof(v)) < 0)
76 LOG_WARN("failed to set TCP_NODELAY ", ERRNO());
77 }
78 return fd;
79}
80
81template<typename Stream> inline
82Stream* new_stream(int family, int protocol = 0, bool nonblocking = true) {

Callers 3

new_streamFunction · 0.70
bindMethod · 0.70
bindMethod · 0.70

Calls 2

set_fd_nonblockingFunction · 0.85
ERRNOClass · 0.50

Tested by

no test coverage detected