You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It would be nice to add join/lease operations to the UDPSocket to facilitate the joining/leaving of multicast groups. Today the operation can be achieved by using setsockopt and could be already made a bit more user friendly by addressing the Issue #125. However, the most user-friendly solution would be to add join/leave operations straight on the UDPSocket class.
Below a possible implementation for the functionality:
private func createMembershipRequest(_ ip: String, _ ifaddr: String) -> ip_mreq {
let group = inet_addr(ip)
let iface = inet_addr(ifaddr)
var imr = ip_mreq()
imr.imr_multiaddr.s_addr = group;
imr.imr_interface.s_addr = iface
return imr
}
public func join(group mcastAddr: String, iface ifname: String) throws {
let imr = self.createMembershipRequest(mcastAddr, ifname)
try self.descriptor.setOption(level: IPPROTO_IP, name: IP_ADD_MEMBERSHIP, value: imr)
}
public func leave(group mcastAddr: String, iface ifname: String) throws {
let imr = self.createMembershipRequest(mcastAddr, ifname)
try self.descriptor.setOption(level: IPPROTO_IP, name: IP_ADD_MEMBERSHIP, value: imr)
}
Ciao, Kydos
The text was updated successfully, but these errors were encountered:
I've done a bunch of other enhancements on my branch. Let me finalise my contribution and then I'll do a Pull Request. Among other things I have a buffer a la java.nio.ByteBuffer to contribute along with send/rcv operations on the socket that operate on this ByteBuffer w/o allocating memory at each time.
I'll probably have things cleaned up and committed on my branch by later today.
It would be nice to add join/lease operations to the UDPSocket to facilitate the joining/leaving of multicast groups. Today the operation can be achieved by using setsockopt and could be already made a bit more user friendly by addressing the Issue #125. However, the most user-friendly solution would be to add join/leave operations straight on the UDPSocket class.
Below a possible implementation for the functionality:
Ciao, Kydos
The text was updated successfully, but these errors were encountered: