Fix mg_socket_if_get_conn_addr for UDP sockets

Remote address is not associated with an outgoing UDP socket.
Instead, it is stored in mg_connection.sa

PUBLISHED_FROM=16f82ee8a69b995d684ec96b8db6b5591cd400db
This commit is contained in:
Deomid Ryabkov 2017-04-18 13:26:46 +01:00 committed by Cesanta Bot
parent 57e32b87c7
commit 1cee8a16b9

View File

@ -3792,6 +3792,10 @@ void mg_sock_to_str(sock_t sock, char *buf, size_t len, int flags) {
void mg_socket_if_get_conn_addr(struct mg_connection *nc, int remote,
union socket_address *sa) {
if ((nc->flags & MG_F_UDP) && remote) {
memcpy(sa, &nc->sa, sizeof(*sa));
return;
}
mg_sock_get_addr(nc->sock, remote, sa);
}