Struct unreliable_message::network::Sender
[−]
[src]
pub struct Sender { pub datagram_length: u16, pub replication: u8, // some fields omitted }
The sending end of an unreliable message socket.
Fields
datagram_length: u16
replication: u8
Methods
impl Sender
[src]
fn from_socket(
socket: UdpSocket,
datagram_length: u16,
replication: u8
) -> Sender
socket: UdpSocket,
datagram_length: u16,
replication: u8
) -> Sender
Constructs a sender from a socket.
datagram_length
is the max-size of a UDP packet.replication
is the amout of times that a chunk will get re-sent.
replication
should almost always be 1
, and rarely 2
or above.
fn enqueue<T: ToSocketAddrs>(
&mut self,
message: Vec<u8>,
addrs: T
) -> UnrResult<()>
&mut self,
message: Vec<u8>,
addrs: T
) -> UnrResult<()>
Adds a message to the queue of chunks to send out.
fn send_one(&mut self) -> UnrResult<bool>
Attempts to send one UDP packet over the network.
The size of the UDP packet is bounded by self.datagram_length
.
Returns
- Err(e) if an error occurred during sending.
- Ok(true) if there are more messages in the queue.
- Ok(false) if theere are no more messages in the queue.
fn send_all(&mut self) -> UnrResult<()>
Attemts to send all UDP packets by repeatedly calling send_one
.