From c366f2bbcdd0dd744a3cccbc8af74c46e7d3e497 Mon Sep 17 00:00:00 2001 From: Oleg Hahm Date: Fri, 20 Nov 2015 22:07:56 +0100 Subject: [PATCH] sockets: perform implicit bind during sendto() A client should not require to explicitly call bind() to receive packets, but is expected to receive replies sent to the ephemeral port that was selected as a source port by the UDP implementation. --- sys/posix/sockets/posix_sockets.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/sys/posix/sockets/posix_sockets.c b/sys/posix/sockets/posix_sockets.c index a54e3260e4..356dc5707e 100644 --- a/sys/posix/sockets/posix_sockets.c +++ b/sys/posix/sockets/posix_sockets.c @@ -728,12 +728,11 @@ ssize_t recvfrom(int socket, void *restrict buffer, size_t length, int flags, switch (s->type) { #ifdef MODULE_CONN_UDP case SOCK_DGRAM: - if ((res = conn_udp_recvfrom(&s->conn.udp, buffer, length, addr, &addr_len, - port)) < 0) { + if ((res = conn_udp_recvfrom(&s->conn.udp, buffer, length, addr, + &addr_len, port)) < 0) { errno = -res; return -1; } - break; #endif #ifdef MODULE_CONN_IP