pub struct FabricSocket { /* private fields */ }Expand description
A network socket bound to a leased fabric network interface.
Wraps a UDP socket with the bandwidth guarantee from the underlying
NetLease. On native targets, delegates to std::net::UdpSocket.
§Example
use grafos_net::FabricSocket;
use grafos_std::net::NetBuilder;
let lease = NetBuilder::new().min_bandwidth(1_000_000_000).acquire()?;
let sock = FabricSocket::new(lease)?;
assert_eq!(sock.bandwidth(), 1_000_000_000);
assert_eq!(sock.interface_name(), "eth0");Implementations§
Source§impl FabricSocket
impl FabricSocket
Sourcepub fn connect(addr: SocketAddr) -> Result<Self>
pub fn connect(addr: SocketAddr) -> Result<Self>
Create a connected socket using a default (zero-bandwidth) lease.
Acquires a network lease with no bandwidth constraint and connects to the given address.
§Errors
Returns an I/O error if lease acquisition or the connect fails.
§Example
use grafos_net::FabricSocket;
use std::net::SocketAddr;
let addr: SocketAddr = "127.0.0.1:9999".parse().unwrap();
let sock = FabricSocket::connect(addr)?;
assert!(sock.bandwidth() > 0);Sourcepub fn connect_with_bandwidth(addr: SocketAddr, min_bw: u64) -> Result<Self>
pub fn connect_with_bandwidth(addr: SocketAddr, min_bw: u64) -> Result<Self>
Create a connected socket with a minimum bandwidth guarantee.
Acquires a network lease with at least min_bw bits per second,
then connects to the given address.
§Errors
Returns an I/O error if the bandwidth requirement cannot be met or if the connect fails.
§Example
use grafos_net::FabricSocket;
use std::net::SocketAddr;
let addr: SocketAddr = "127.0.0.1:9999".parse().unwrap();
let sock = FabricSocket::connect_with_bandwidth(addr, 1_000_000_000)?;
assert!(sock.bandwidth() >= 1_000_000_000);Sourcepub fn connect_to(&self, addr: SocketAddr) -> Result<()>
pub fn connect_to(&self, addr: SocketAddr) -> Result<()>
Sourcepub fn local_addr(&self) -> Result<SocketAddr>
pub fn local_addr(&self) -> Result<SocketAddr>
Returns the local address this socket is bound to.
§Errors
Returns an I/O error if the address cannot be retrieved.
Sourcepub fn interface_name(&self) -> &str
pub fn interface_name(&self) -> &str
Returns the leased interface name.