MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / anetUnixGenericConnect

Function anetUnixGenericConnect

src/anet.c:386–412  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 3

anetCreateSocketFunction · 0.85
anetNonBlockFunction · 0.85
anetSetErrorFunction · 0.85

Tested by

no test coverage detected