pub trait CreateSocket {
// Required methods
fn udp_bind_blocking(
&self,
endpoint: SocketAddr,
) -> Result<UdpSocket, Error>;
fn udp_bind(
&self,
endpoint: SocketAddr,
) -> impl Future<Output = Result<UdpSocket, Error>> + Send;
fn tcp_listen_blocking(
&self,
local_endpoint: SocketAddr,
) -> Result<TcpListener, Error>;
fn tcp_listen(
&self,
local_endpoint: SocketAddr,
) -> impl Future<Output = Result<TcpListener, Error>> + Send;
fn bound_tcp_ports_blocking(&self) -> Result<Vec<u16>, Error>;
fn bound_tcp_ports(
&self,
) -> impl Future<Output = Result<Vec<u16>, Error>> + Send;
fn tcp_connect_blocking(
&self,
local_endpoint: SocketAddr,
remote_endpoint: SocketAddr,
) -> Result<TcpStream, Error>;
fn tcp_connect(
&self,
local_endpoint: SocketAddr,
remote_endpoint: SocketAddr,
) -> impl Future<Output = Result<TcpStream, Error>> + Send;
fn raw_open_blocking(
&self,
ipv4: bool,
ip_protocol: IpProtocol,
) -> Result<RawSocket, Error>;
fn raw_open(
&self,
ipv4: bool,
ip_protocol: IpProtocol,
) -> impl Future<Output = Result<RawSocket, Error>> + Send;
}Expand description
API for creating sockets over a HasChannel.
Required Methods§
Sourcefn udp_bind_blocking(&self, endpoint: SocketAddr) -> Result<UdpSocket, Error>
fn udp_bind_blocking(&self, endpoint: SocketAddr) -> Result<UdpSocket, Error>
Create and bind a new UdpSocket to the given local endpoint.
Sourcefn udp_bind(
&self,
endpoint: SocketAddr,
) -> impl Future<Output = Result<UdpSocket, Error>> + Send
fn udp_bind( &self, endpoint: SocketAddr, ) -> impl Future<Output = Result<UdpSocket, Error>> + Send
Asynchronously create and bind a new UdpSocket to the given local endpoint.
Sourcefn tcp_listen_blocking(
&self,
local_endpoint: SocketAddr,
) -> Result<TcpListener, Error>
fn tcp_listen_blocking( &self, local_endpoint: SocketAddr, ) -> Result<TcpListener, Error>
Create a new TcpListener on the given endpoint.
Sourcefn tcp_listen(
&self,
local_endpoint: SocketAddr,
) -> impl Future<Output = Result<TcpListener, Error>> + Send
fn tcp_listen( &self, local_endpoint: SocketAddr, ) -> impl Future<Output = Result<TcpListener, Error>> + Send
Asynchronously create a new TcpListener on the given endpoint.
Sourcefn bound_tcp_ports_blocking(&self) -> Result<Vec<u16>, Error>
fn bound_tcp_ports_blocking(&self) -> Result<Vec<u16>, Error>
Snapshot the set of local ports that currently have an explicit TCP listener.
Read-only: answered from the listener registry without touching the packet ingress /
accept path. The fallback-TCP-handler manager uses this to avoid binding a competing
any-IP listener on a port the embedder is already serving with an explicit tcp_listen.
Sourcefn bound_tcp_ports(
&self,
) -> impl Future<Output = Result<Vec<u16>, Error>> + Send
fn bound_tcp_ports( &self, ) -> impl Future<Output = Result<Vec<u16>, Error>> + Send
Asynchronously snapshot the set of local ports that currently have an explicit TCP
listener. See CreateSocket::bound_tcp_ports_blocking.
Sourcefn tcp_connect_blocking(
&self,
local_endpoint: SocketAddr,
remote_endpoint: SocketAddr,
) -> Result<TcpStream, Error>
fn tcp_connect_blocking( &self, local_endpoint: SocketAddr, remote_endpoint: SocketAddr, ) -> Result<TcpStream, Error>
Create a new TcpStream bound to the given local address and connected to
the given remote.
Waits for the handshake to complete before returning.
Sourcefn tcp_connect(
&self,
local_endpoint: SocketAddr,
remote_endpoint: SocketAddr,
) -> impl Future<Output = Result<TcpStream, Error>> + Send
fn tcp_connect( &self, local_endpoint: SocketAddr, remote_endpoint: SocketAddr, ) -> impl Future<Output = Result<TcpStream, Error>> + Send
Asynchronously create a new TcpStream bound to the given local address and
connected to the given remote.
Waits for the handshake to complete before returning.
Sourcefn raw_open_blocking(
&self,
ipv4: bool,
ip_protocol: IpProtocol,
) -> Result<RawSocket, Error>
fn raw_open_blocking( &self, ipv4: bool, ip_protocol: IpProtocol, ) -> Result<RawSocket, Error>
Create a new RawSocket on the selected ip version and protocol.
NB: this will intercept all matching traffic, even if you have other sockets open.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".