| 380 | } |
| 381 | |
| 382 | int 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 | |
| 410 | static int anetListen(char *err, int s, struct sockaddr *sa, socklen_t len, int backlog) { |
| 411 | if (bind(s,sa,len) == -1) { |
nothing calls this directly
no test coverage detected