pub struct Server { /* private fields */ }Expand description
A polling-based socket object which manages inbound uflow connections.
Implementations
sourceimpl Server
impl Server
sourcepub fn bind<A: ToSocketAddrs>(
addr: A,
max_peer_count: usize,
peer_config: Config
) -> Result<Self, Error>
pub fn bind<A: ToSocketAddrs>(
addr: A,
max_peer_count: usize,
peer_config: Config
) -> Result<Self, Error>
Opens a UDP socket and creates a corresponding Server object. The UDP socket is
bound to the provided address, and configured to be non-blocking. Any errors resulting from
socket initialization are forwarded to the caller.
The server will limit the number of concurrent, non-zombie connections to max_peer_count,
and will silently ignore connection requests which would exceed that limit. Valid incoming
connections will be initialized according to peer_config.
sourcepub fn bind_any_ipv4(
max_peer_count: usize,
peer_config: Config
) -> Result<Self, Error>
pub fn bind_any_ipv4(
max_peer_count: usize,
peer_config: Config
) -> Result<Self, Error>
Equivalent to calling bind() with address
(std::net::Ipv4Addr::UNSPECIFIED, 0).
sourcepub fn bind_any_ipv6(
max_peer_count: usize,
peer_config: Config
) -> Result<Self, Error>
pub fn bind_any_ipv6(
max_peer_count: usize,
peer_config: Config
) -> Result<Self, Error>
Equivalent to calling bind() with address
(std::net::Ipv6Addr::UNSPECIFIED, 0).
sourcepub fn incoming(&mut self) -> impl Iterator<Item = Peer>
pub fn incoming(&mut self) -> impl Iterator<Item = Peer>
Returns a number of Peer objects representing new connections since the
last call to incoming(). Any connections which have since entered the
zombie state (timed out) will not be returned.
sourcepub fn step(&mut self)
pub fn step(&mut self)
Processes UDP frames received since the last call to step(), and
sends any pending outbound frames (acknowledgements, keep-alives, packet data, etc.).
Current, non-zombie Peer objects will be updated as relevant data is
received. Call Peer::poll_events() after calling this method
to retrieve incoming packets and connection status updates for an individual peer.
sourcepub fn flush(&mut self)
pub fn flush(&mut self)
Sends any pending outbound frames (acknowledgements, keep-alives, packet data, etc.).
sourcepub fn address(&self) -> SocketAddr
pub fn address(&self) -> SocketAddr
Returns the local address of the internal UDP socket.
Auto Trait Implementations
impl !RefUnwindSafe for Server
impl !Send for Server
impl !Sync for Server
impl Unpin for Server
impl !UnwindSafe for Server
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more