pub struct TcpServer { /* private fields */ }Expand description
TCP proxy server for a Cloud SQL instance.
Binds a TCP listener on construction, guaranteeing the socket is ready to accept connections once the struct is obtained.
Implementations§
Source§impl TcpServer
impl TcpServer
Sourcepub async fn new(
dialer: Arc<Dialer>,
address: SocketAddr,
peer_filter: PeerFilter,
) -> Result<Self, Error>
pub async fn new( dialer: Arc<Dialer>, address: SocketAddr, peer_filter: PeerFilter, ) -> Result<Self, Error>
Bind a TCP proxy for a Cloud SQL instance.
The socket is bound immediately — if this returns Ok, the server
is ready to accept connections.
Sourcepub async fn new_localhost_v4(dialer: Arc<Dialer>) -> Result<Self, Error>
pub async fn new_localhost_v4(dialer: Arc<Dialer>) -> Result<Self, Error>
Bind a TCP proxy on localhost with an OS-assigned port.
Accepts all incoming connections since the listener is bound to
loopback and only reachable from the local machine. Use TcpServer::new
if you need to filter on loopback.
Use TcpServer::local_addr to discover the assigned port.
Sourcepub async fn new_localhost_v6(dialer: Arc<Dialer>) -> Result<Self, Error>
pub async fn new_localhost_v6(dialer: Arc<Dialer>) -> Result<Self, Error>
Bind a TCP proxy on IPv6 localhost with an OS-assigned port.
Accepts all incoming connections since the listener is bound to
loopback and only reachable from the local machine. Use TcpServer::new
if you need to filter on loopback.
Use TcpServer::local_addr to discover the assigned port.
Sourcepub fn local_addr(&self) -> SocketAddr
pub fn local_addr(&self) -> SocketAddr
Return the local address this server is bound to.