Skip to main content

SocketOptions

Struct SocketOptions 

Source
pub struct SocketOptions<'a> { /* private fields */ }
Expand description

Live get and set on an open socket.

use net_io::{Keepalive, Linger};
let conn = net_io::connect("127.0.0.1:7000")?;
conn.options().set_keepalive(Some(Keepalive::DEFAULT))?;
conn.options().set_linger(Linger::Abortive)?;
let effective = conn.options().set_receive_buffer(256 * 1024)?;
println!("receive buffer is {effective} bytes");

Implementations§

Source§

impl SocketOptions<'_>

Source

pub fn nodelay(&self) -> Result<bool, NetError>

TCP_NODELAY.

§Errors

Os when the OS call fails.

Source

pub fn set_nodelay(&self, on: bool) -> Result<(), NetError>

Sets TCP_NODELAY.

§Errors

Os when the OS call fails.

Source

pub fn keepalive(&self) -> Result<Option<Keepalive>, NetError>

Keepalive probes (None = off).

§Errors

Os when the OS call fails.

Source

pub fn set_keepalive(&self, k: Option<Keepalive>) -> Result<(), NetError>

Sets keepalive probes (None = off).

§Errors

InvalidConfig for a zero value or a count above 255 on Windows; Os.

Source

pub fn linger(&self) -> Result<Linger, NetError>

Linger at close.

§Errors

Os when the OS call fails.

Source

pub fn set_linger(&self, l: Linger) -> Result<(), NetError>

Sets linger at close.

§Errors

Os when the OS call fails.

Source

pub fn send_buffer(&self) -> Result<u32, NetError>

The effective SO_SNDBUF.

§Errors

Os when the OS call fails.

Source

pub fn set_send_buffer(&self, bytes: u32) -> Result<u32, NetError>

Sets SO_SNDBUF and returns the effective value (Linux doubles it).

§Errors

Os when the OS call fails.

Source

pub fn receive_buffer(&self) -> Result<u32, NetError>

The effective SO_RCVBUF.

§Errors

Os when the OS call fails.

Source

pub fn set_receive_buffer(&self, bytes: u32) -> Result<u32, NetError>

Sets SO_RCVBUF and returns the effective value (Linux doubles it).

§Errors

Os when the OS call fails.

Source

pub fn ttl(&self) -> Result<u8, NetError>

The hop limit.

§Errors

Os when the OS call fails.

Source

pub fn set_ttl(&self, hops: u8) -> Result<(), NetError>

Sets the hop limit.

§Errors

Os when the OS call fails.

Trait Implementations§

Source§

impl<'a> Debug for SocketOptions<'a>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for SocketOptions<'a>

§

impl<'a> RefUnwindSafe for SocketOptions<'a>

§

impl<'a> Send for SocketOptions<'a>

§

impl<'a> Sync for SocketOptions<'a>

§

impl<'a> Unpin for SocketOptions<'a>

§

impl<'a> UnsafeUnpin for SocketOptions<'a>

§

impl<'a> UnwindSafe for SocketOptions<'a>

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