From 7c942914b1d7114667a19bb299d06cee15c02aad Mon Sep 17 00:00:00 2001 From: Dengfeng Liu Date: Wed, 19 Apr 2017 11:39:46 +0800 Subject: [PATCH] Update xkcp_server.c --- xkcp_server.c | 27 +-------------------------- 1 file changed, 1 insertion(+), 26 deletions(-) diff --git a/xkcp_server.c b/xkcp_server.c index 4829c33..7e5e544 100644 --- a/xkcp_server.c +++ b/xkcp_server.c @@ -60,31 +60,6 @@ iqueue_head * get_xkcp_task_list() return &xkcp_task_list; } -static struct evconnlistener *set_xkcp_mon_listener(struct event_base *base, void *ptr) -{ - struct sockaddr_in sin; - char *addr = get_iface_ip(xkcp_get_param()->local_interface); - if (!addr) { - debug(LOG_ERR, "get_iface_ip [%s] failed", xkcp_get_param()->local_interface); - exit(0); - } - - memset(&sin, 0, sizeof(sin)); - sin.sin_family = AF_INET; - sin.sin_addr.s_addr = inet_addr(addr); - sin.sin_port = htons(mport); - - struct evconnlistener * listener = evconnlistener_new_bind(base, xkcp_mon_accept_cb, ptr, - LEV_OPT_CLOSE_ON_FREE|LEV_OPT_CLOSE_ON_EXEC|LEV_OPT_REUSEABLE, - -1, (struct sockaddr*)&sin, sizeof(sin)); - if (!listener) { - debug(LOG_ERR, "Couldn't create listener: [%s]", strerror(errno)); - exit(0); - } - - return listener; -} - static void timer_event_cb(evutil_socket_t fd, short event, void *arg) { xkcp_timer_event_cb(arg, &xkcp_task_list); @@ -189,7 +164,7 @@ int server_main_loop() int xkcp_fd = set_xkcp_listener(); - mon_listener = set_xkcp_mon_listener(base, NULL); + mon_listener = set_xkcp_mon_listener(base, mport); xkcp_event = event_new(base, xkcp_fd, EV_READ|EV_PERSIST, xkcp_rcv_cb, base); event_add(xkcp_event, NULL);