[−][src]Struct reliudp::RUdpSocket
A RUdp Client Socket
Represents a connection between you (the host) and the remote. You can send messages, receive messages and poll it for various events.
Once dropped, the socket will send a "terminate" message to the remote before shutting down.
A RUdpServer
holds 0, 1 or more of them.
Methods
impl RUdpSocket
[src]
pub fn connect<A: ToSocketAddrs>(remote_addr: A) -> IoResult<RUdpSocket>
[src]
Creates a Socket and connects to the remote instantly.
This will fail ONLY if there is something wrong with the network,
preventing it to create a UDP Socket. This is NOT blocking,
so any timeout event or things or the like will arrive as SocketEvent
s.
The socket will be created with the status SynSent, after which there will be 2 outcomes:
- The remote answered SynAck, and we set the status as "Connected"
- The remote did not answer, and we will get a timeout
pub fn set_timeout_delay(&mut self, timeout_delay: u64)
[src]
Set the number of iterations required before a remote is set as "dead".
For instance, if your tick is every 50ms, and your timeout_delay is of 24, then roughly 50*24=1200ms (=1.2s) without a message from the remote will cause a timeout error.
pub fn set_timeout_delay_with(
&mut self,
milliseconds: u64,
tick_interval_milliseconds: u64
)
[src]
&mut self,
milliseconds: u64,
tick_interval_milliseconds: u64
)
pub fn set_heartbeat_delay(&mut self, heartbeat_delay: u64)
[src]
Set the number of iterations required before we send a "heartbeat" message to the remote, to make sure they don't consider us as timed out.
pub fn set_heartbeat_delay_with(
&mut self,
milliseconds: u64,
heartbeat_interval_milliseconds: u64
)
[src]
&mut self,
milliseconds: u64,
heartbeat_interval_milliseconds: u64
)
pub fn drain_events<'a>(&'a mut self) -> impl Iterator<Item = SocketEvent> + 'a
[src]
Drains socket events for this Socket.
This is one of the 2 ways to loop over all incoming events. See the examples for how to use it.
pub fn next_event(&mut self) -> Option<SocketEvent>
[src]
Gets the next socket event for this socket.
pub fn send_data(&mut self, data: Arc<[u8]>, message_type: MessageType)
[src]
Send data to the remote.
pub fn send_end(&mut self) -> Result<()>
[src]
Same as terminate
, but leave the Socket alive.
This is mostly useful if you want to still receive the data the other remote is currently sending at this time. However, note that no acks will be sent, so its usefulness is still limited.
pub fn terminate(self) -> IoResult<()>
[src]
Terminates the socket, by sending a "Ended" event to the remote.
pub fn ping(&self) -> Option<u32>
[src]
Returns the ping to the remote as ms
Returns None if the ping has not been computed yet
pub fn next_tick(&mut self) -> IoResult<()>
[src]
Internal processing for this single source
Must be done before draining events. Even if there are no events,
you will want to re-send acks, keep track of sent data, etc. next_tick
does that for you.
Do NOT use this method if you have multiple remotes for a single UdpSocket (a single port):
all packets not coming from the right remote (matching IP and port) will be discarded!
This warning applies if this socket has been borrowed from a RUdpServer
as well,
because all the remotes are sharing the same port.
pub fn status(&self) -> SocketStatus
[src]
pub fn should_clear(&self) -> bool
[src]
Returns whether or not you should clear this RUdp client.
pub fn local_addr(&self) -> SocketAddr
[src]
pub fn remote_addr(&self) -> SocketAddr
[src]
Trait Implementations
impl Debug for RUdpSocket
[src]
impl Drop for RUdpSocket
[src]
Auto Trait Implementations
impl RefUnwindSafe for RUdpSocket
impl Send for RUdpSocket
impl Sync for RUdpSocket
impl Unpin for RUdpSocket
impl UnwindSafe for RUdpSocket
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,