pub struct Server { /* private fields */ }
Expand description
Acts as a host for inbound uflow
connections.
Implementations§
source§impl Server
impl Server
sourcepub fn bind<A: ToSocketAddrs>(addr: A, config: Config) -> Result<Self, Error>
pub fn bind<A: ToSocketAddrs>(addr: A, config: Config) -> Result<Self, Error>
Opens a non-blocking UDP socket bound to the provided address, and returns a corresponding
Server
object.
Error Handling
Any errors resulting from socket initialization are forwarded to the caller. This function will panic if the provided server configuration is not valid.
sourcepub fn bind_any_ipv4(config: Config) -> Result<Self, Error>
pub fn bind_any_ipv4(config: Config) -> Result<Self, Error>
Equivalent to calling bind()
with address
(std::net::Ipv4Addr::UNSPECIFIED, 0)
.
sourcepub fn bind_any_ipv6(config: Config) -> Result<Self, Error>
pub fn bind_any_ipv6(config: Config) -> Result<Self, Error>
Equivalent to calling bind()
with address
(std::net::Ipv6Addr::UNSPECIFIED, 0)
.
sourcepub fn address(&self) -> SocketAddr
pub fn address(&self) -> SocketAddr
Returns the local address of the internal UDP socket.
sourcepub fn step(&mut self) -> impl Iterator<Item = Event>
pub fn step(&mut self) -> impl Iterator<Item = Event>
Flushes outbound frames, then processes as many inbound frames as possible from the
internal socket. Returns an iterator of Event
objects to signal connection events and
deliver received packets for each client.
Note 1: All events are considered delivered, even if the iterator is not consumed until the end.
Note 2: Internally, uflow
uses the leaky bucket
algorithm to control the rate at which UDP
frames are sent. To ensure that data is transferred smoothly, this function should be
called regularly and relatively frequently.
sourcepub fn client(
&self,
client_addr: &SocketAddr
) -> Option<&Rc<RefCell<RemoteClient>>>
pub fn client(
&self,
client_addr: &SocketAddr
) -> Option<&Rc<RefCell<RemoteClient>>>
Returns a reference to the RemoteClient
with the given address. Returns None
if no
such client exists.
sourcepub fn drop(&mut self, client_addr: &SocketAddr)
pub fn drop(&mut self, client_addr: &SocketAddr)
Immediately terminates the connection with the given address. No further data will be sent or received, and a timeout error will be generated on the client.