From 02078d831dd6eb109c839794613fadbeeacc9073 Mon Sep 17 00:00:00 2001 From: sebas Date: Thu, 2 Mar 2017 11:01:55 -0500 Subject: [PATCH] Added a getter method for the destination IP address. This is useful when the beginPacket method is called with the hostname parameter. --- src/WiFiUdp.cpp | 5 +++++ src/WiFiUdp.h | 2 ++ 2 files changed, 7 insertions(+) diff --git a/src/WiFiUdp.cpp b/src/WiFiUdp.cpp index e55c9656..1ef15e2b 100644 --- a/src/WiFiUdp.cpp +++ b/src/WiFiUdp.cpp @@ -287,3 +287,8 @@ uint16_t WiFiUDP::remotePort() { return _rcvPort; } + +IPAddress WiFiUDP::destinationIP() +{ + return _sndIP; +} diff --git a/src/WiFiUdp.h b/src/WiFiUdp.h index d9616823..2b9dbf13 100644 --- a/src/WiFiUdp.h +++ b/src/WiFiUdp.h @@ -84,6 +84,8 @@ class WiFiUDP : public UDP { // Return the port of the host who sent the current incoming packet virtual uint16_t remotePort(); + // Return the IP address of the destination host. Useful when beginPacket(const char *host, uint16_t port) method is used. + virtual IPAddress destinationIP(); }; #endif /* WIFIUDP_H */