Struct zircon_object::ipc::Socket[][src]

pub struct Socket { /* fields omitted */ }

Bidirectional streaming IPC transport.

SYNOPSIS

Sockets are a bidirectional stream transport. Unlike channels, sockets only move data (not handles).

Implementations

impl Socket[src]

pub fn create(flags: u32) -> ZxResult<(Arc<Self>, Arc<Self>)>[src]

Create a socket.

pub fn write(&self, data: &[u8]) -> ZxResult<usize>[src]

Write data to the socket. If successful, the number of bytes actually written are returned.

A SOCKET_STREAM(default) socket write can be short if the socket does not have enough space for all of data. Otherwise, if the socket was already full, the call returns ZxError::SHOULD_WAIT.

A SOCKET_DATAGRAM socket write is never short. If the socket has insufficient space for data, it writes nothing and returns ZxError::SHOULD_WAIT. Attempting to write a packet larger than the datagram socket’s capacity will fail with ZxError::OUT_OF_RANGE.

pub fn read(&self, peek: bool, data: &mut [u8]) -> ZxResult<usize>[src]

Read data from the socket. If successful, the number of bytes actually read are returned.

If the socket was created with SOCKET_DATAGRAM, this method reads only the first available datagram in the socket (if one is present). If data is too small for the datagram, then the read will be truncated, and any remaining bytes in the datagram will be discarded.

If peek is true, leave the message in the socket. Otherwise consume the message.

pub fn get_info(&self) -> SocketInfo[src]

Get information of the socket.

pub fn shutdown(&self, read: bool, write: bool) -> ZxResult[src]

Prevent reading or writing.

pub fn set_read_threshold(&self, threshold: usize) -> ZxResult[src]

Set the read threshold of the socket.

When the bytes queued on the socket (available for reading) is equal to or greater than this value, the SOCKET_READ_THRESHOLD signal is asserted. Read threshold signalling is disabled by default (and when set, writing a value of 0 for this property disables it).

pub fn set_write_threshold(&self, threshold: usize) -> ZxResult[src]

Set the write threshold of the socket.

When the space available for writing on the socket is equal to or greater than this value, the SOCKET_WRITE_THRESHOLD signal is asserted. Write threshold signalling is disabled by default (and when set, writing a value of 0 for this property disables it).

pub fn get_rx_tx_threshold(&self) -> (usize, usize)[src]

Get the read and write thresholds of the socket.

Trait Implementations

impl Debug for Socket[src]

impl Drop for Socket[src]

impl KernelObject for Socket[src]

Auto Trait Implementations

impl !RefUnwindSafe for Socket

impl Send for Socket

impl Sync for Socket

impl Unpin for Socket

impl !UnwindSafe for Socket

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Downcast for T where
    T: Any
[src]

impl<T> DowncastSync for T where
    T: Send + Sync + Any
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.