From 0d1606ff2323028cf5a26a900d2074c842710afd Mon Sep 17 00:00:00 2001 From: sg Date: Thu, 26 Feb 2015 21:31:48 +0100 Subject: [PATCH] Fixed last commit: can only check for bound sockets, not for unbound. There's some work to do for IPv6 in TCP... --- src/core/tcp.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/core/tcp.c b/src/core/tcp.c index 3cbde688..31333a51 100644 --- a/src/core/tcp.c +++ b/src/core/tcp.c @@ -593,17 +593,14 @@ tcp_listen_dual_with_backlog(struct tcp_pcb *pcb, u8_t backlog) struct tcp_pcb *lpcb; struct tcp_pcb_listen *l; - /* Dual listen only works on bound pcbs (or else we cannot check for - duplicate port use. */ - if (pcb->local_port == 0) { - return NULL; - } - /* Check that there's noone listening on this port already - (don't check the IP address since we'll set it to ANY */ - for(l = tcp_listen_pcbs.listen_pcbs; l != NULL; l = l->next) { - if (l->local_port == pcb->local_port) { - /* this port is already used */ - return NULL; + if (pcb->local_port != 0) { + /* Check that there's noone listening on this port already + (don't check the IP address since we'll set it to ANY */ + for(l = tcp_listen_pcbs.listen_pcbs; l != NULL; l = l->next) { + if (l->local_port == pcb->local_port) { + /* this port is already used */ + return NULL; + } } }