Struct laminar::Socket[][src]

pub struct Socket { /* fields omitted */ }

A reliable UDP socket implementation with configurable reliability and ordering guarantees.

Implementations

impl Socket[src]

pub fn bind<A: ToSocketAddrs>(addresses: A) -> Result<Self>[src]

Binds to the socket and then sets up ActiveConnections to manage the “connections”. Because UDP connections are not persistent, we can only infer the status of the remote endpoint by looking to see if they are still sending packets or not

pub fn bind_any() -> Result<Self>[src]

Binds to any local port on the system, if available

pub fn bind_any_with_config(config: Config) -> Result<Self>[src]

Binds to any local port on the system, if available, with a given config

pub fn bind_with_config<A: ToSocketAddrs>(
    addresses: A,
    config: Config
) -> Result<Self>
[src]

Binds to the socket and then sets up ActiveConnections to manage the “connections”. Because UDP connections are not persistent, we can only infer the status of the remote endpoint by looking to see if they are still sending packets or not

This function allows you to configure laminar with the passed configuration.

pub fn get_packet_sender(&self) -> Sender<Packet>[src]

Returns a handle to the packet sender which provides a thread-safe way to enqueue packets to be processed. This should be used when the socket is busy running its polling loop in a separate thread.

pub fn get_event_receiver(&self) -> Receiver<SocketEvent>[src]

Returns a handle to the event receiver which provides a thread-safe way to retrieve events from the socket. This should be used when the socket is busy running its polling loop in a separate thread.

pub fn send(&mut self, packet: Packet) -> Result<()>[src]

Sends a single packet

pub fn recv(&mut self) -> Option<SocketEvent>[src]

Receives a single packet

pub fn start_polling(&mut self)[src]

Runs the polling loop with the default ‘1ms’ sleep duration. This should run in a spawned thread since calls to self.manual_poll are blocking.

pub fn start_polling_with_duration(&mut self, sleep_duration: Option<Duration>)[src]

Runs the polling loop with a specified sleep duration. This should run in a spawned thread since calls to self.manual_poll are blocking.

pub fn manual_poll(&mut self, time: Instant)[src]

Processes any inbound/outbound packets and handle idle clients

pub fn local_addr(&self) -> Result<SocketAddr>[src]

Returns the local socket address

Trait Implementations

impl Debug for Socket[src]

fn fmt(&self, f: &mut Formatter<'_>) -> Result[src]

Formats the value using the given formatter. Read more

Auto Trait Implementations

impl RefUnwindSafe for Socket

impl Send for Socket

impl Sync for Socket

impl Unpin for Socket

impl UnwindSafe for Socket

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>, 

pub fn vzip(self) -> V