Skip to content
Snippets Groups Projects
Commit 1cc40202 authored by Daniel Müller's avatar Daniel Müller :speech_balloon:
Browse files

Add default constructor for UdpSocket

- Default UdpSocket constructor binds to 0.0.0.0:0
parent e065c448
No related branches found
No related tags found
No related merge requests found
Pipeline #70349 passed
...@@ -35,6 +35,13 @@ private: ...@@ -35,6 +35,13 @@ private:
public: 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 * @brief Create a UdpSocket that will be bound to the local address and
* port that is specified in the SockAddr. * port that is specified in the SockAddr.
......
...@@ -7,6 +7,10 @@ ...@@ -7,6 +7,10 @@
#include <poll.h> #include <poll.h>
UdpSocket::UdpSocket()
: UdpSocket{"0.0.0.0", 0}
{ }
UdpSocket::UdpSocket(SockAddr _local) UdpSocket::UdpSocket(SockAddr _local)
: local{_local}, sockfd{0} : local{_local}, sockfd{0}
{ {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment