#include "sysdep_decls.h"
#include "msgbase.h"
#include "tools.h"
+#include "config.h"
#ifndef HAVE_SNPRINTF
#include <stdarg.h>
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);
+ }
}