afb-socket: Handle listening on all interfaces 19/17519/1
authorJose Bollo <jose.bollo@iot.bzh>
Tue, 30 Oct 2018 09:55:49 +0000 (10:55 +0100)
committerJosé Bollo <jose.bollo@iot.bzh>
Tue, 30 Oct 2018 15:39:55 +0000 (16:39 +0100)
Change-Id: I909493166f98f152e5aeb02a72f40bc3c58b42b2
Signed-off-by: Jose Bollo <jose.bollo@iot.bzh>
src/afb-socket.c

index f4ee7e1..63de2cf 100644 (file)
@@ -178,6 +178,11 @@ static int open_tcp(const char *spec, int server)
        memset(&hint, 0, sizeof hint);
        hint.ai_family = AF_INET;
        hint.ai_socktype = SOCK_STREAM;
+       if (server) {
+               hint.ai_flags = AI_PASSIVE;
+               if (host[0] == 0 || (host[0] == '*' && host[1] == 0))
+                       host = NULL;
+       }
        rc = getaddrinfo(host, service, &hint, &rai);
        if (rc != 0) {
                errno = EINVAL;