Struct snarkos_node_tcp::Tcp
source · pub struct Tcp(/* private fields */);
Expand description
The central object responsible for handling connections.
Implementations§
source§impl Tcp
impl Tcp
sourcepub fn listening_addr(&self) -> Result<SocketAddr>
pub fn listening_addr(&self) -> Result<SocketAddr>
Returns the listening address; returns an error if Tcp was not configured to listen for inbound connections.
sourcepub fn is_connected(&self, addr: SocketAddr) -> bool
pub fn is_connected(&self, addr: SocketAddr) -> bool
Checks whether the provided address is connected.
sourcepub fn is_connecting(&self, addr: SocketAddr) -> bool
pub fn is_connecting(&self, addr: SocketAddr) -> bool
Checks if Tcp is currently setting up a connection with the provided address.
sourcepub fn num_connected(&self) -> usize
pub fn num_connected(&self) -> usize
Returns the number of active connections.
sourcepub fn num_connecting(&self) -> usize
pub fn num_connecting(&self) -> usize
Returns the number of connections that are currently being set up.
sourcepub fn connected_addrs(&self) -> Vec<SocketAddr>
pub fn connected_addrs(&self) -> Vec<SocketAddr>
Returns a list containing addresses of active connections.
sourcepub fn connecting_addrs(&self) -> Vec<SocketAddr>
pub fn connecting_addrs(&self) -> Vec<SocketAddr>
Returns a list containing addresses of pending connections.
sourcepub fn known_peers(&self) -> &KnownPeers
pub fn known_peers(&self) -> &KnownPeers
Returns a reference to the collection of statistics of known peers.
source§impl Tcp
impl Tcp
sourcepub async fn connect(&self, addr: SocketAddr) -> Result<()>
pub async fn connect(&self, addr: SocketAddr) -> Result<()>
Connects to the provided SocketAddr
.
sourcepub async fn disconnect(&self, addr: SocketAddr) -> bool
pub async fn disconnect(&self, addr: SocketAddr) -> bool
Disconnects from the provided SocketAddr
.
source§impl Tcp
impl Tcp
sourcepub async fn enable_listener(&self) -> Result<SocketAddr>
pub async fn enable_listener(&self) -> Result<SocketAddr>
Spawns a task that listens for incoming connections.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Tcp
impl Send for Tcp
impl Sync for Tcp
impl Unpin for Tcp
impl !UnwindSafe for Tcp
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more