Skip to content

Commit

Permalink
fix knx socket options (closes #1422)
Browse files Browse the repository at this point in the history
  • Loading branch information
john30 committed Dec 29, 2024
1 parent c42d06d commit d25551e
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/lib/knx/knxnet.h
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,9 @@ class KnxNetConnection : public KnxConnection {
const char* open() override {
close();
int fd = socketConnect(m_url && m_url[0] ? m_url : SYSTEM_MULTICAST_IP_STR,
SYSTEM_MULTICAST_PORT, IPPROTO_UDP, nullptr, 0x02);
SYSTEM_MULTICAST_PORT, IPPROTO_UDP, &m_multicast,
// do not use connect() as it will limit incoming to the mcast src which is not the case
0x01);
if (fd < 0) {
return "create socket";
}
Expand Down Expand Up @@ -596,7 +598,7 @@ class KnxNetConnection : public KnxConnection {
}
d[0] = tpci;
logTelegram(true, c, l, d);
ssize_t sent = ::send(m_sock, buf, totalLen, MSG_NOSIGNAL);
ssize_t sent = sendto(m_sock, buf, totalLen, MSG_NOSIGNAL, (sockaddr*)&m_multicast, sizeof(m_multicast));
if (sent < 0) {
return "send error";
}
Expand Down Expand Up @@ -633,6 +635,9 @@ class KnxNetConnection : public KnxConnection {
/** the URL to connect to. */
const char* m_url;

/** the multicast address to send to. */
struct sockaddr_in m_multicast;

/** the socket if connected, or 0. */
int m_sock;

Expand Down

0 comments on commit d25551e

Please sign in to comment.