[][src]Struct laminar::Socket

pub struct Socket { /* fields omitted */ }

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

Methods

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]

Bind to any local port on the system, if available

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

Bind 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(&mut 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(&mut 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]

Send a packet

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

Receive a packet

pub fn start_polling(&mut self)[src]

Entry point to the run loop. This should run in a spawned thread since calls to poll.poll are blocking. We will default this to sleeping for 1ms.

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

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

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

Process any inbound/outbound packets and handle idle clients

Set the link conditioner for this socket. See LinkConditioner for further details.

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

Get the local socket address

Trait Implementations

impl Debug for Socket[src]

Auto Trait Implementations

impl Send for Socket

impl Unpin for Socket

impl Sync for Socket

impl UnwindSafe for Socket

impl RefUnwindSafe for Socket

Blanket Implementations

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

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

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.

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.

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

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

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

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