Skip to main content

SrtSocket

Struct SrtSocket 

Source
pub struct SrtSocket { /* private fields */ }
Available on crate feature 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

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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).

Source

pub async fn send_bytes(&mut self, payload: Bytes) -> Result<()>

Like send but takes ownership of an already-built Bytes, so the hand-off to the driver task does not copy it.

Source

pub fn peer_addr(&self) -> SocketAddr

The peer’s socket address.

Source

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.

Source

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.

Trait Implementations§

Source§

impl Debug for SrtSocket

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Drop for SrtSocket

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.