From 1cc402021b6c0ecd88660171be069fd1d2271353 Mon Sep 17 00:00:00 2001
From: Daniel M <daniel.q.mueller@stud.h-da.de>
Date: Wed, 12 May 2021 00:57:07 +0200
Subject: [PATCH] Add default constructor for UdpSocket

- Default UdpSocket constructor binds to 0.0.0.0:0
---
 inc/udpsocket.hpp | 7 +++++++
 src/udpsocket.cpp | 4 ++++
 2 files changed, 11 insertions(+)

diff --git a/inc/udpsocket.hpp b/inc/udpsocket.hpp
index 83d03a5..8e0a364 100644
--- a/inc/udpsocket.hpp
+++ b/inc/udpsocket.hpp
@@ -35,6 +35,13 @@ private:
 
 public:
 
+    /**
+     * @brief Create a UdpSocket that will be bound to Ipv4 0.0.0.0 and the 
+     * port 0. This will use a random free port and is useful for sending 
+     * only.
+     */
+    UdpSocket();
+
     /**
      * @brief Create a UdpSocket that will be bound to the local address and 
      * port that is specified in the SockAddr. 
diff --git a/src/udpsocket.cpp b/src/udpsocket.cpp
index 91744c2..89234e4 100644
--- a/src/udpsocket.cpp
+++ b/src/udpsocket.cpp
@@ -7,6 +7,10 @@
 #include <poll.h>
 
 
+UdpSocket::UdpSocket()
+    : UdpSocket{"0.0.0.0", 0}
+{ }
+
 UdpSocket::UdpSocket(SockAddr _local)
     : local{_local}, sockfd{0}
 {
-- 
GitLab