3 #if !defined(NO_UNIX_DOMAIN_SOCKETS)
6 UBind(int sockfd
, const char *const astr
, const int nTries
, const int reuseFlag
)
11 struct sockaddr_un localAddr
;
14 ualen
= MakeSockAddrUn(&localAddr
, astr
);
15 (void) unlink(localAddr
.sun_path
);
17 if (reuseFlag
!= kReUseAddrNo
) {
18 /* This is mostly so you can quit the server and re-run it
19 * again right away. If you don't do this, the OS may complain
20 * that the address is still in use.
23 onsize
= (int) sizeof(on
);
24 (void) setsockopt(sockfd
, SOL_SOCKET
, SO_REUSEADDR
,
25 (char *) &on
, onsize
);
29 /* Try binding a few times, in case we get Address in Use
32 if (bind(sockfd
, (struct sockaddr
*) &localAddr
, ualen
) == 0) {
35 if (i
== (unsigned int) nTries
) {
38 /* Give the OS time to clean up the old socket,
51 UListen(int sfd
, int backlog
)
53 return (listen(sfd
, backlog
));