MCPcopy Create free account
hub / github.com/F-Stack/f-stack / anetUnixGenericConnect

Function anetUnixGenericConnect

app/redis-6.2.6/src/anet.c:382–408  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

380}
381
382int anetUnixGenericConnect(char *err, const char *path, int flags)
383{
384 int s;
385 struct sockaddr_un sa;
386
387 if ((s = anetCreateSocket(err,AF_LOCAL)) == ANET_ERR)
388 return ANET_ERR;
389
390 sa.sun_family = AF_LOCAL;
391 strncpy(sa.sun_path,path,sizeof(sa.sun_path)-1);
392 if (flags & ANET_CONNECT_NONBLOCK) {
393 if (anetNonBlock(err,s) != ANET_OK) {
394 close(s);
395 return ANET_ERR;
396 }
397 }
398 if (connect(s,(struct sockaddr*)&sa,sizeof(sa)) == -1) {
399 if (errno == EINPROGRESS &&
400 flags & ANET_CONNECT_NONBLOCK)
401 return s;
402
403 anetSetError(err, "connect: %s", strerror(errno));
404 close(s);
405 return ANET_ERR;
406 }
407 return s;
408}
409
410static int anetListen(char *err, int s, struct sockaddr *sa, socklen_t len, int backlog) {
411 if (bind(s,sa,len) == -1) {

Callers

nothing calls this directly

Calls 6

anetCreateSocketFunction · 0.85
strncpyFunction · 0.85
anetNonBlockFunction · 0.85
anetSetErrorFunction · 0.85
closeFunction · 0.70
connectFunction · 0.70

Tested by

no test coverage detected