From dde9c509ed9798a4c9b85ce757b18f39ea456010 Mon Sep 17 00:00:00 2001 From: dmiller Date: Mon, 1 Jul 2024 16:17:42 +0000 Subject: [PATCH] Allow nsock_iod_get_communication_info() to get latest UDP peer --- nsock/src/nsock_core.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/nsock/src/nsock_core.c b/nsock/src/nsock_core.c index 6c93669cf..599e9d57b 100644 --- a/nsock/src/nsock_core.c +++ b/nsock/src/nsock_core.c @@ -638,11 +638,15 @@ static int do_actual_read(struct npool *ms, struct nevent *nse) { err = socket_errno(); } else { + if (peerlen > 0 +#ifdef WIN32 /* Windows will ignore src_addr and addrlen arguments to recvfrom on TCP * sockets, so peerlen is still sizeof(peer) and peer is junk. Instead, * only set this if it's not already set. */ - if (peerlen > 0 && iod->peerlen == 0) { + && (iod->lastproto == IPPROTO_UDP || iod->peerlen == 0) +#endif + ) { assert(peerlen <= sizeof(iod->peer)); memcpy(&iod->peer, &peer, peerlen); iod->peerlen = peerlen;