pub struct SharedUdpSocket { /* private fields */ }
Expand description
A UDP socket that can easily be shared amongst a bunch of different futures.
Implementations§
Create a new SharedUdpSocket
from a UdpSocket
.
Sourcepub fn endpoint(&self, addr: SocketAddr) -> UdpEndpoint
pub fn endpoint(&self, addr: SocketAddr) -> UdpEndpoint
Creates a UdpEndpoint
object which receives all packets that arrive from the given
address. UdpEndpoint
can also be used as a Sink
to send packets. If another
UdpEndpoint
with the given address already exists then it will no longer receive packets
since the newly created UdpEndpoint
will take precedence.
Sourcepub fn try_endpoint(&self, addr: SocketAddr) -> Option<UdpEndpoint>
pub fn try_endpoint(&self, addr: SocketAddr) -> Option<UdpEndpoint>
Creates a UdpEndpoint
object which receives all packets that arrive from the given
address. UdpEndpoint
can also be used as a Sink
to send packets. Unlike the endpoint
method, this method will not replace any pre-existing UdpEndpoint
associated with the
given address and will instead return None
if one exists.
Sourcepub fn steal(self) -> Option<UdpSocket>
pub fn steal(self) -> Option<UdpSocket>
Steals the udp socket (if it hasn’t already been stolen) causing all other
SharedUdpSocket
and UdpEndpoint
streams to end.