From 3e8f57160a4d1d9e2510bb37767c236351c34a41 Mon Sep 17 00:00:00 2001 From: Xie Han <63350856@qq.com> Date: Sun, 28 Jul 2024 17:55:18 +0800 Subject: [PATCH] Fix 'sendto()' failure on a connected UDP socket. --- src/kernel/Communicator.cc | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/kernel/Communicator.cc b/src/kernel/Communicator.cc index a5bbd8de2c..91e97c4c07 100644 --- a/src/kernel/Communicator.cc +++ b/src/kernel/Communicator.cc @@ -176,8 +176,13 @@ int CommMessageIn::feedback(const void *buf, size_t size) if (!entry->ssl) { - entry->target->get_addr(&addr, &addrlen); - return sendto(entry->sockfd, buf, size, 0, addr, addrlen); + if (entry->service) + { + entry->target->get_addr(&addr, &addrlen); + return sendto(entry->sockfd, buf, size, 0, addr, addrlen); + } + else + return write(entry->sockfd, buf, size); } if (size == 0)