Struct utp::UtpStream [] [src]

pub struct UtpStream { /* fields omitted */ }

A structure that represents a uTP (Micro Transport Protocol) stream between a local socket and a remote socket.

The connection will be closed when the value is dropped (either explicitly or when it goes out of scope).

The default maximum retransmission retries is 5, which translates to about 16 seconds. It can be changed by calling set_max_retransmission_retries. Notice that the initial congestion timeout is 500 ms and doubles with each timeout.

Examples

use utp::UtpStream;
use std::io::{Read, Write};

let mut stream = UtpStream::bind("127.0.0.1:1234").expect("Error binding stream");
let _ = stream.write(&[1]);
let _ = stream.read(&mut [0; 1000]);

Methods

impl UtpStream
[src]

Creates a uTP stream listening on the given address.

The address type can be any implementer of the ToSocketAddr trait. See its documentation for concrete examples.

If more than one valid address is specified, only the first will be used.

Opens a uTP connection to a remote host by hostname or IP address.

The address type can be any implementer of the ToSocketAddr trait. See its documentation for concrete examples.

If more than one valid address is specified, only the first will be used.

Gracefully closes connection to peer.

This method allows both peers to receive all packets still in flight.

Returns the socket address of the local half of this uTP connection.

Changes the maximum number of retransmission retries on the underlying socket.

Try to send a keepalive packet to the peer, ensuring the connection stays active.

Methods from Deref<Target = UtpSocket>

Returns the socket address that this socket was created from.

Returns the socket address of the remote peer of this UTP connection.

Trait Implementations

impl Read for UtpStream
[src]

Pull some bytes from this source into the specified buffer, returning how many bytes were read. Read more

Read all bytes until EOF in this source, placing them into buf. Read more

Read all bytes until EOF in this source, placing them into buf. Read more

Read the exact number of bytes required to fill buf. Read more

Creates a "by reference" adaptor for this instance of Read. Read more

Transforms this Read instance to an Iterator over its bytes. Read more

🔬 This is a nightly-only experimental API. (io)

the semantics of a partial read/write of where errors happen is currently unclear and may change

Transforms this Read instance to an Iterator over chars. Read more

Creates an adaptor which will chain this stream with another. Read more

Creates an adaptor which will read at most limit bytes from it. Read more

impl Write for UtpStream
[src]

Write a buffer into this object, returning how many bytes were written. Read more

Flush this output stream, ensuring that all intermediately buffered contents reach their destination. Read more

Attempts to write an entire buffer into this write. Read more

Writes a formatted string into this writer, returning any error encountered. Read more

Creates a "by reference" adaptor for this instance of Write. Read more

impl Deref for UtpStream
[src]

The resulting type after dereferencing

The method called to dereference a value