From a351c42134aabf53110de1766004ec8b15b3dd6c Mon Sep 17 00:00:00 2001 From: yhchen Date: Wed, 23 Feb 2022 17:55:20 +0800 Subject: [PATCH] Fix UdpServer recv port incorrect --- Sources/yudpsocket.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/yudpsocket.c b/Sources/yudpsocket.c index e59a725..c5dc2a3 100644 --- a/Sources/yudpsocket.c +++ b/Sources/yudpsocket.c @@ -80,7 +80,7 @@ int yudpsocket_recive(int socket_fd, char *outdata, int expted_len, char *remote int len = (int)recvfrom(socket_fd, outdata, expted_len, 0, (struct sockaddr *)&cli_addr, &clilen); char *clientip = inet_ntoa(cli_addr.sin_addr); memcpy(remoteip, clientip, strlen(clientip)); - *remoteport = cli_addr.sin_port; + *remoteport = ntohs(cli_addr.sin_port); return len; }