MCPcopy Create free account
hub / github.com/acl-dev/acl / sock_open

Function sock_open

lib_acl/samples/udp/udp.cpp:114–138  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

112}
113
114static SOCK_UDP *sock_open(const char *addr)
115{
116 SOCK_UDP *sock;
117 struct addrinfo *res0, *res;
118 int fd;
119
120 res0 = host_addrinfo(addr);
121 if (res0 == NULL)
122 return NULL;
123
124 fd = bind_addr(res0, &res);
125 if (fd == ACL_SOCKET_INVALID) {
126 acl_msg_error("%s(%d): invalid socket", __FILE__, __LINE__);
127 freeaddrinfo(res0);
128 return NULL;
129 }
130
131 sock = (SOCK_UDP *) acl_mycalloc(1, sizeof(SOCK_UDP));
132 sock->fd = fd;
133 memcpy(&sock->sa_local, res->ai_addr, res->ai_addrlen);
134 sock->sa_local_len = res->ai_addrlen;
135
136 freeaddrinfo(res0);
137 return sock;
138}
139
140SOCK_UDP *udp_client_open(const char *local, const char *peer)
141{

Callers 2

udp_client_openFunction · 0.85
udp_server_openFunction · 0.85

Calls 5

acl_msg_errorFunction · 0.85
memcpyFunction · 0.85
host_addrinfoFunction · 0.70
bind_addrFunction · 0.70
freeaddrinfoFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…