From ce9792fc49e4722a927b790c08ad83bdad673e7e Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Sun, 9 Aug 2015 18:15:16 +0200 Subject: EDI: Do not use misbehaving UdpPacket --- src/UdpSocket.cpp | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'src/UdpSocket.cpp') 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 @@ -228,6 +227,30 @@ int UdpSocket::send(UdpPacket &packet) } +/** + * Send an UDP packet + * + * return 0 if ok, -1 if error + */ +int UdpSocket::send(std::vector data, InetAddress destination) +{ +#ifdef DUMP + TRACE_CLASS("UdpSocket", "send(vector)"); +#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 -- cgit v1.2.3