diff options
author | Matthias P. Braendli <matthias.braendli@mpb.li> | 2016-11-12 16:30:30 +0100 |
---|---|---|
committer | Matthias P. Braendli <matthias.braendli@mpb.li> | 2016-11-12 16:30:30 +0100 |
commit | 96b4dc4efca1b164f79a7f7394449866f034ac31 (patch) | |
tree | 101b796f40fee444c8193ccc3e13cf5644c83d5f /src/UdpSocket.cpp | |
parent | 5132756f09c7a0dafe4644db92718ee3d1a58d6c (diff) | |
parent | fedab89cd4625617b3e481f1f59ba0fc97b7305b (diff) | |
download | dabmux-96b4dc4efca1b164f79a7f7394449866f034ac31.tar.gz dabmux-96b4dc4efca1b164f79a7f7394449866f034ac31.tar.bz2 dabmux-96b4dc4efca1b164f79a7f7394449866f034ac31.zip |
Merge branch 'next' into servicelinking
Diffstat (limited to 'src/UdpSocket.cpp')
-rw-r--r-- | src/UdpSocket.cpp | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/src/UdpSocket.cpp b/src/UdpSocket.cpp index 020e3f5..ccdd7ed 100644 --- a/src/UdpSocket.cpp +++ b/src/UdpSocket.cpp @@ -37,19 +37,19 @@ using namespace std; UdpSocket::UdpSocket() : listenSocket(INVALID_SOCKET) { - init_sock(0, ""); + reinit(0, ""); } UdpSocket::UdpSocket(int port) : listenSocket(INVALID_SOCKET) { - init_sock(port, ""); + reinit(port, ""); } UdpSocket::UdpSocket(int port, const std::string& name) : listenSocket(INVALID_SOCKET) { - init_sock(port, name); + reinit(port, name); } @@ -67,7 +67,7 @@ int UdpSocket::setBlocking(bool block) return 0; } -int UdpSocket::init_sock(int port, const std::string& name) +int UdpSocket::reinit(int port, const std::string& name) { if (listenSocket != INVALID_SOCKET) { ::close(listenSocket); @@ -98,6 +98,16 @@ int UdpSocket::init_sock(int port, const std::string& name) return 0; } +int UdpSocket::close() +{ + if (listenSocket != INVALID_SOCKET) { + ::close(listenSocket); + } + + listenSocket = INVALID_SOCKET; + + return 0; +} UdpSocket::~UdpSocket() { |