pub struct MulticastSocket { /* private fields */ }
Expand description
A UDP socket.
After creating a UdpSocket by binding it to a socket address, data can be sent to and received from any other socket address.
Although UDP is a connectionless protocol, this implementation provides an interface to set an address where data should be sent and received from. After setting a remote address with connect, data can be sent to and received from that address with send and recv.
As stated in the User Datagram Protocol’s specification in IETF RFC 768, UDP is an unordered, unreliable protocol;
This client is only used to receive multicast packets and does not send multicast packets.
Implementations§
Source§impl Socket
impl Socket
Sourcepub fn new(multicast: Ipv4Addr, bind: SocketAddr) -> Result<Self, Error>
pub fn new(multicast: Ipv4Addr, bind: SocketAddr) -> Result<Self, Error>
Creates a UDP socket from the given address.
You need to specify the multicast group for the udp session to join to the specified multicast group.
Note that only IPV4 is supported.
Sourcepub fn read(&self) -> Option<(u64, Bytes)>
pub fn read(&self) -> Option<(u64, Bytes)>
Reads packets sent from the multicast server.
Because the packets are reordered, it is possible to read out more than one packet at a time.
Note that there may be packet loss.