diff options
author | Matthias P. Braendli <matthias.braendli@mpb.li> | 2015-08-09 18:15:16 +0200 |
---|---|---|
committer | Matthias P. Braendli <matthias.braendli@mpb.li> | 2015-08-09 18:15:16 +0200 |
commit | ce9792fc49e4722a927b790c08ad83bdad673e7e (patch) | |
tree | 25d6d097dfeea29bd997873c18fdebce9172763c /src/UdpSocket.cpp | |
parent | f9bdf5bec2f3778c4fef99da698a8a7a6f182fe0 (diff) | |
download | dabmux-ce9792fc49e4722a927b790c08ad83bdad673e7e.tar.gz dabmux-ce9792fc49e4722a927b790c08ad83bdad673e7e.tar.bz2 dabmux-ce9792fc49e4722a927b790c08ad83bdad673e7e.zip |
EDI: Do not use misbehaving UdpPacket
Diffstat (limited to 'src/UdpSocket.cpp')
-rw-r--r-- | src/UdpSocket.cpp | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/src/UdpSocket.cpp b/src/UdpSocket.cpp index 74730e9..a1a7935 100644 --- a/src/UdpSocket.cpp +++ b/src/UdpSocket.cpp @@ -202,7 +202,6 @@ int UdpSocket::receive(UdpPacket &packet) return 0; } - /** * Send an UDP packet. * @param packet The UDP packet to be sent. It includes the data and the @@ -229,6 +228,30 @@ int UdpSocket::send(UdpPacket &packet) /** + * Send an UDP packet + * + * return 0 if ok, -1 if error + */ +int UdpSocket::send(std::vector<uint8_t> data, InetAddress destination) +{ +#ifdef DUMP + TRACE_CLASS("UdpSocket", "send(vector<uint8_t>)"); +#endif + int ret = sendto(listenSocket, &data[0], data.size(), 0, + destination.getAddress(), sizeof(*destination.getAddress())); + if (ret == SOCKET_ERROR +#ifndef _WIN32 + && errno != ECONNREFUSED +#endif + ) { + setInetError("Can't send UDP packet"); + return -1; + } + return 0; +} + + +/** * Must be called to receive data on a multicast address. * @param groupname The multica st address to join. |