Struct Socket
pub(crate) struct Socket(OwnedFd);Expand description
Client socket on the IPC router.
The router assigns a port when the socket is created.
Tuple Fields§
§0: OwnedFdImplementations§
§impl Socket
impl Socket
pub(crate) fn new() -> Result<Self>
pub(crate) fn into_async(self) -> Result<AsyncFd<Self>>
pub(crate) fn into_async(self) -> Result<AsyncFd<Self>>
Registers the socket with the tokio reactor for reading.
The router never reports a socket as writable. Flow control resumes with a message instead.
§Panics
Panics if called outside of a tokio runtime.
pub(crate) fn bind_control_port(&self) -> Result<()>
pub(crate) fn bind_control_port(&self) -> Result<()>
Turns the socket into a control port, which receives a message for every server that is added or removed.
pub(crate) fn lookup(
&self,
service: u32,
filter: Filter,
) -> Result<impl ExactSizeIterator<Item = Server> + use<>>
pub(crate) fn lookup( &self, service: u32, filter: Filter, ) -> Result<impl ExactSizeIterator<Item = Server> + use<>>
Returns the servers of a QMI service.
pub(crate) fn connect(&self, to: Port) -> Result<()>
pub(crate) fn connect(&self, to: Port) -> Result<()>
Connects the socket to a server. Self::send then sends to it.
Only a connected socket reports a hang up (POLLHUP | POLLERR). See
ServiceWatcher::wait_removed
for when the router reports it.
pub(crate) fn send(&self, packet: &[u8]) -> Result<()>
pub(crate) fn send(&self, packet: &[u8]) -> Result<()>
Sends a packet to the connected server without blocking.
Fails with io::ErrorKind::WouldBlock if flow control stops sending.
Until irsc_util has loaded the IPC security rules, the router blocks
the call while it holds the socket lock, even though the call is
non-blocking. The wait is uninterruptible and never ends if
irsc_util doesn’t run.
pub(crate) fn try_recv(&self) -> Result<Received>
pub(crate) fn try_recv(&self) -> Result<Received>
Reads the next packet without blocking.
Fails with io::ErrorKind::WouldBlock if no packet is queued.
pub(crate) fn try_recv_control(&self, buf: &mut [u8]) -> Result<Option<usize>>
pub(crate) fn try_recv_control(&self, buf: &mut [u8]) -> Result<Option<usize>>
Reads the next control message into buf without blocking and
returns its length.
Returns None for a packet that isn’t a control message, which has
no sender, or that doesn’t fit into buf. The packet is dropped.
Fails with io::ErrorKind::WouldBlock if no packet is queued.
fn next_packet_len(&self) -> Result<usize>
fn next_packet_len(&self) -> Result<usize>
Returns the size of the next queued packet, or 0 if there is none.