version 1.19, 2012/04/11 06:05:43 |
version 1.20, 2012/06/27 06:53:13 |
|
|
struct listen *f; |
struct listen *f; |
|
|
sock = socket(AF_UNIX, SOCK_STREAM, 0); |
sock = socket(AF_UNIX, SOCK_STREAM, 0); |
if (sock < 0) { |
if (sock < 0) |
perror("socket"); |
err(1, "socket"); |
exit(1); |
|
} |
|
if (unlink(path) < 0 && errno != ENOENT) { |
if (unlink(path) < 0 && errno != ENOENT) { |
perror("unlink"); |
perror("unlink"); |
goto bad_close; |
goto bad_close; |
|
|
if (f == NULL) |
if (f == NULL) |
goto bad_close; |
goto bad_close; |
f->path = strdup(path); |
f->path = strdup(path); |
if (f->path == NULL) { |
if (f->path == NULL) |
perror("strdup"); |
err(1, "strdup"); |
exit(1); |
|
} |
|
f->fd = sock; |
f->fd = sock; |
f->next = listen_list; |
f->next = listen_list; |
listen_list = f; |
listen_list = f; |
|
|
aihints.ai_socktype = SOCK_STREAM; |
aihints.ai_socktype = SOCK_STREAM; |
aihints.ai_protocol = IPPROTO_TCP; |
aihints.ai_protocol = IPPROTO_TCP; |
error = getaddrinfo(host, serv, &aihints, &ailist); |
error = getaddrinfo(host, serv, &aihints, &ailist); |
if (error) { |
if (error) |
fprintf(stderr, "%s: %s\n", addr, gai_strerror(error)); |
errx(1, "%s: %s", addr, gai_strerror(error)); |
exit(1); |
|
} |
|
|
|
/* |
/* |
* for each address, try create a listening socket bound on |
* for each address, try create a listening socket bound on |