pub struct SrtSocket { /* private fields */ }tokio only.Expand description
A handle to an established SRT connection over UDP.
Created by SrtSocket::connect (caller role) or
SrtListener::accept (listener role). The protocol itself runs on a
background tokio task the handle owns; send enqueues an
application payload and recv awaits a delivered one.
Dropping the handle sends the peer a SHUTDOWN (§3.2.7) and aborts the
driver task.
Implementations§
Source§impl SrtSocket
impl SrtSocket
Sourcepub async fn connect<A: ToSocketAddrs>(
remote_addr: A,
config: HandshakeConfig,
) -> Result<Self>
pub async fn connect<A: ToSocketAddrs>( remote_addr: A, config: HandshakeConfig, ) -> Result<Self>
Connect to a remote SRT peer as a Caller.
§Encryption
With crypto set in the HandshakeConfig, the adapter negotiates
keys in the handshake and encrypts outgoing / decrypts incoming data
packets (AES-CTR, draft section 6) on this connection.
§Errors
Error::Rejected carries the peer’s RejectionReason;
Error::HandshakeTimedOut means the peer never answered within the
handshake budget; Error::Handshake wraps an engine failure with the
stage it happened in.
Sourcepub async fn connect_with<A: ToSocketAddrs>(
remote_addr: A,
config: HandshakeConfig,
io: IoConfig,
) -> Result<Self>
pub async fn connect_with<A: ToSocketAddrs>( remote_addr: A, config: HandshakeConfig, io: IoConfig, ) -> Result<Self>
Like Self::connect, with explicit timeouts and datagram size.
Sourcepub async fn connect_from<A: ToSocketAddrs>(
local_addr: SocketAddr,
remote_addr: A,
config: HandshakeConfig,
) -> Result<Self>
pub async fn connect_from<A: ToSocketAddrs>( local_addr: SocketAddr, remote_addr: A, config: HandshakeConfig, ) -> Result<Self>
Connect from a specific local address.
§Encryption
Like Self::connect, negotiates and applies payload encryption when
crypto is set in the HandshakeConfig.
Sourcepub async fn connect_from_with<A: ToSocketAddrs>(
local_addr: SocketAddr,
remote_addr: A,
config: HandshakeConfig,
io: IoConfig,
) -> Result<Self>
pub async fn connect_from_with<A: ToSocketAddrs>( local_addr: SocketAddr, remote_addr: A, config: HandshakeConfig, io: IoConfig, ) -> Result<Self>
Like Self::connect_from, with explicit timeouts and datagram size.
Sourcepub async fn rendezvous<A: ToSocketAddrs>(
local_addr: SocketAddr,
remote_addr: A,
config: HandshakeConfig,
) -> Result<Self>
pub async fn rendezvous<A: ToSocketAddrs>( local_addr: SocketAddr, remote_addr: A, config: HandshakeConfig, ) -> Result<Self>
Establish a connection with a peer in Rendezvous mode
(draft-sharabayko-srt-01 §4.3.2): both sides bind a known local port
and send to each other’s address at the same time, so neither is
Caller or Listener; the cookie contest picks Initiator / Responder.
Runs the sans-IO crate::rendezvous::RendezvousHandshake over a UDP
socket bound to local_addr (its port must be the one the peer targets).
§Errors
Error::Rejected carries the peer’s RejectionReason;
Error::HandshakeTimedOut means the peer never completed the
exchange within the handshake budget.
Sourcepub async fn rendezvous_with<A: ToSocketAddrs>(
local_addr: SocketAddr,
remote_addr: A,
config: HandshakeConfig,
io: IoConfig,
) -> Result<Self>
pub async fn rendezvous_with<A: ToSocketAddrs>( local_addr: SocketAddr, remote_addr: A, config: HandshakeConfig, io: IoConfig, ) -> Result<Self>
Like Self::rendezvous, with explicit timeouts and datagram size.
Sourcepub async fn send(&mut self, payload: &[u8]) -> Result<()>
pub async fn send(&mut self, payload: &[u8]) -> Result<()>
Enqueue a payload for transmission to the peer.
Returns once the payload is handed to the driver task — actual transmission, ACK/NAK handling, and retransmission all happen on that task. Waits (applying backpressure) while the sender already holds a full flow window of unacknowledged packets or the hand-off queue is full. Fails only if the driver task has stopped (peer shut down, went silent, or a connection error).
Sourcepub async fn send_bytes(&mut self, payload: Bytes) -> Result<()>
pub async fn send_bytes(&mut self, payload: Bytes) -> Result<()>
Sourcepub fn peer_addr(&self) -> SocketAddr
pub fn peer_addr(&self) -> SocketAddr
The peer’s socket address.
Sourcepub async fn recv(&mut self) -> Result<Option<Bytes>>
pub async fn recv(&mut self) -> Result<Option<Bytes>>
Receive the next payload, waiting until one is available.
Returns None once the peer has shut down (or the driver task has
stopped) and no further payloads will arrive.
Sourcepub fn stats(&self) -> SocketStats
pub fn stats(&self) -> SocketStats
A snapshot of this connection’s internal-backpressure drop counters (item 4) — datagrams or delivered payloads this adapter’s own bounded channels dropped because they were full, not wire-level loss.