summaryrefslogtreecommitdiffstats
path: root/src/UdpSocket.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/UdpSocket.cpp')
-rw-r--r--src/UdpSocket.cpp25
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.