pub struct Client<T, C> { /* private fields */ }Expand description
The central client responsible for managing the connection to the server.
This client handles TCP stream creation and delegates UDP session management
to a dedicated UdpDispatcher. It ensures the connection stays alive
through a retry mechanism.
Implementations§
Source§impl<T, C> Client<T, C>where
T: Initiator<Connection = C>,
C: Connection,
impl<T, C> Client<T, C>where
T: Initiator<Connection = C>,
C: Connection,
Sourcepub async fn new(
transport: T,
secret: Secret,
options: Option<Bytes>,
) -> Result<Self>
pub async fn new( transport: T, secret: Secret, options: Option<Bytes>, ) -> Result<Self>
Creates a new Client and establishes a connection to the server.
This involves performing a handshake and spawning a background task to handle incoming UDP datagrams.
Sourcepub fn open_associate(&self) -> UdpSession<T, C>
pub fn open_associate(&self) -> UdpSession<T, C>
Establishes a new UDP session through the tunnel.
This returns a UdpSession object, which provides a socket-like API
for sending and receiving UDP datagrams over the existing connection.
Sourcepub async fn open_bidirectional(&self, dest_addr: Address) -> Result<C::Stream>
pub async fn open_bidirectional(&self, dest_addr: Address) -> Result<C::Stream>
Opens a new bidirectional stream for TCP-like communication.
This method negotiates a new stream with the server, which will then connect to the specified destination address.