* Got bounce messages working (mostly ... testers, please beat this up!)
[citadel.git] / citadel / dynloader.c
index 4d26b594526294387d3a4e628cf30bc67b62797a..be6d6353a1e0fe1c1602fcbff392481884f1518b 100644 (file)
@@ -25,6 +25,7 @@
 #include "sysdep_decls.h"
 #include "msgbase.h"
 #include "tools.h"
+#include "config.h"
 
 #ifndef HAVE_SNPRINTF
 #include <stdarg.h>
@@ -240,9 +241,18 @@ void CtdlRegisterServiceHook(int tcp_port,
        newfcn->tcp_port = tcp_port;
        newfcn->h_greeting_function = h_greeting_function;
        newfcn->h_command_function = h_command_function;
-       newfcn->msock = (-1);
-       ServiceHookTable = newfcn;
-       lprintf(5, "Registered a new service (TCP port %d)\n", tcp_port);
+       newfcn->msock = ig_tcp_server(tcp_port, config.c_maxsessions);
+
+       if (newfcn->msock >= 0) {
+               ServiceHookTable = newfcn;
+               lprintf(5, "Registered a new service (TCP port %d)\n",
+                       tcp_port);
+       }
+       else {
+               lprintf(2, "ERROR: could not bind to TCP port %d.\n",
+                       tcp_port);
+               phree(newfcn);
+       }
 }