summaryrefslogtreecommitdiff
path: root/src/shared/socket-util.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2013-11-06 22:30:35 +0100
committerLennart Poettering <lennart@poettering.net>2013-11-06 23:03:12 +0100
commit175a3d25d0e8596d4ba0759aea3f89ee228e7d6d (patch)
tree95f09c22413d3109170fe0098ae1bdc1741c6354 /src/shared/socket-util.c
parenteceb8483e5a02e8e337486b89719a3b99cfcb7ce (diff)
active: rework make_socket_fd() to be based on socket_address_listen()
Among other things this makes sure we set SO_REUSEADDR which is immensely useful.
Diffstat (limited to 'src/shared/socket-util.c')
-rw-r--r--src/shared/socket-util.c39
1 files changed, 0 insertions, 39 deletions
diff --git a/src/shared/socket-util.c b/src/shared/socket-util.c
index 954686f974..1175795d7c 100644
--- a/src/shared/socket-util.c
+++ b/src/shared/socket-util.c
@@ -568,45 +568,6 @@ bool socket_address_matches_fd(const SocketAddress *a, int fd) {
return false;
}
-int make_socket_fd(const char* address, int flags) {
- SocketAddress a;
- int fd, r;
- _cleanup_free_ char *p = NULL;
-
- r = socket_address_parse(&a, address);
- if (r < 0) {
- log_error("failed to parse socket: %s", strerror(-r));
- return r;
- }
-
- fd = socket(socket_address_family(&a), flags, 0);
- if (fd < 0) {
- log_error("socket(): %m");
- return -errno;
- }
-
- r = socket_address_print(&a, &p);
- if (r < 0) {
- log_error("socket_address_print(): %s", strerror(-r));
- return r;
- }
- log_info("Listening on %s", p);
-
- r = bind(fd, &a.sockaddr.sa, a.size);
- if (r < 0) {
- log_error("bind to %s: %m", address);
- return -errno;
- }
-
- r = listen(fd, SOMAXCONN);
- if (r < 0) {
- log_error("listen on %s: %m", address);
- return -errno;
- }
-
- return fd;
-}
-
static const char* const netlink_family_table[] = {
[NETLINK_ROUTE] = "route",
[NETLINK_FIREWALL] = "firewall",