afb-hsrv: Prepare selection of listening interfaces
[src/app-framework-binder.git] / src / main-afb-daemon.c
index 4fb4792..bb2f0a5 100644 (file)
 #include "jobs.h"
 #include "sig-monitor.h"
 
+#if !defined(DEFAULT_BINDER_INTERFACE)
+#  define DEFAULT_BINDER_INTERFACE NULL
+#endif
+
 /*
    if SELF_PGROUP == 0 the launched command is the group leader
    if SELF_PGROUP != 0 afb-daemon is the group leader
@@ -371,13 +375,20 @@ static struct afb_hsrv *start_http_server()
        NOTICE("Waiting port=%d rootdir=%s", http_port, rootdir);
        NOTICE("Browser URL= http://localhost:%d", http_port);
 
-       rc = afb_hsrv_start(hsrv, (uint16_t) http_port, 15);
+       rc = afb_hsrv_start(hsrv, 15);
        if (!rc) {
                ERROR("starting of httpd failed");
                afb_hsrv_put(hsrv);
                return NULL;
        }
 
+       rc = afb_hsrv_add_interface_tcp(hsrv, DEFAULT_BINDER_INTERFACE, (uint16_t) http_port);
+       if (!rc) {
+               ERROR("setting interface failed");
+               afb_hsrv_put(hsrv);
+               return NULL;
+       }
+
        return hsrv;
 }