[−][src]Struct ublox_cellular::sockets::TcpSocket
A Transmission Control Protocol socket.
A TCP socket may passively listen for connections or actively connect to another endpoint. Note that, for listening sockets, there is no "backlog"; to be able to simultaneously accept several connections, as many sockets must be allocated, or any new connection attempts will be reset.
Implementations
impl<L: ArrayLength<u8>> TcpSocket<L>
[src]
pub fn new(socket_id: u8) -> TcpSocket<L>
[src]
Create a socket using the given buffers.
pub fn handle(&self) -> SocketHandle
[src]
Return the socket handle.
pub fn state(&self) -> State
[src]
Return the connection state, in terms of the TCP state machine.
pub fn set_available_data(&mut self, available_data: usize)
[src]
Set available data.
pub fn get_available_data(&self) -> usize
[src]
Get the number of bytes available to ingress.
pub fn is_active(&self) -> bool
[src]
Return whether a connection is active.
This function returns true if the socket is actively exchanging packets with a remote endpoint. Note that this does not mean that it is possible to send or receive data through the socket; for that, use can_send or can_recv.
If a connection is established, abort will send a reset to the remote endpoint.
In terms of the TCP state machine, the socket must be in the Closed
or
ShutdownForRead
state.
pub fn may_send(&self) -> bool
[src]
Return whether the transmit half of the full-duplex connection is open.
This function returns true if it's possible to send data and have it arrive to the remote endpoint. However, it does not make any guarantees about the state of the transmit buffer, and even if it returns true, send may not be able to enqueue any octets.
In terms of the TCP state machine, the socket must be in the Connected
or
ShutdownForRead
state.
pub fn may_recv(&self) -> bool
[src]
Return whether the receive half of the full-duplex connection is open.
This function returns true if it's possible to receive data from the remote endpoint. It will return true while there is data in the receive buffer, and if there isn't, as long as the remote endpoint has not closed the connection.
In terms of the TCP state machine, the socket must be in the Connected
,
FIN-WAIT-1
, or FIN-WAIT-2
state, or have data in the receive buffer instead.
pub fn can_recv(&self) -> bool
[src]
Check whether the receive half of the full-duplex connection buffer is open (see may_recv, and the receive buffer is not full.
pub fn recv<'b, F, R>(&'b mut self, f: F) -> Result<R, Error> where
F: FnOnce(&'b mut [u8]) -> (usize, R),
[src]
F: FnOnce(&'b mut [u8]) -> (usize, R),
Call f
with the largest contiguous slice of octets in the receive buffer,
and dequeue the amount of elements returned by f
.
This function returns `Err(Error::Illegal) if the receive half of the connection is not open; see may_recv.
pub fn recv_wrapping<'b, F>(&'b mut self, f: F) -> Result<usize, Error> where
F: FnOnce(&'b [u8], Option<&'b [u8]>) -> usize,
[src]
F: FnOnce(&'b [u8], Option<&'b [u8]>) -> usize,
Call f
with a slice of octets in the receive buffer, and dequeue the
amount of elements returned by f
.
If the buffer read wraps around, the second argument of f
will be
Some()
with the remainder of the buffer, such that the combined slice
of the two arguments, makes up the full buffer.
This function returns `Err(Error::Illegal) if the receive half of the connection is not open; see may_recv.
pub fn recv_slice(&mut self, data: &mut [u8]) -> Result<usize, Error>
[src]
Dequeue a sequence of received octets, and fill a slice from it.
This function returns the amount of bytes actually dequeued, which is limited by the amount of free space in the transmit buffer; down to zero.
See also recv.
pub fn peek(&mut self, size: usize) -> Result<&[u8], Error>
[src]
Peek at a sequence of received octets without removing them from the receive buffer, and return a pointer to it.
This function otherwise behaves identically to recv.
pub fn rx_window(&self) -> usize
[src]
pub fn peek_slice(&mut self, data: &mut [u8]) -> Result<usize, Error>
[src]
Peek at a sequence of received octets without removing them from the receive buffer, and fill a slice from it.
This function otherwise behaves identically to recv_slice.
pub fn rx_enqueue_slice(&mut self, data: &[u8]) -> usize
[src]
pub fn recv_queue(&self) -> usize
[src]
Return the amount of octets queued in the receive buffer.
Note that the Berkeley sockets interface does not have an equivalent of this API.
pub fn set_state(&mut self, state: State)
[src]
Trait Implementations
impl<L: ArrayLength<u8>> AnySocket<L> for TcpSocket<L>
[src]
impl<L: ArrayLength<u8>> Into<Socket<L>> for TcpSocket<L>
[src]
Auto Trait Implementations
impl<L> RefUnwindSafe for TcpSocket<L> where
<L as ArrayLength<u8>>::ArrayType: RefUnwindSafe,
<L as ArrayLength<u8>>::ArrayType: RefUnwindSafe,
impl<L> Send for TcpSocket<L>
impl<L> Sync for TcpSocket<L>
impl<L> Unpin for TcpSocket<L> where
<L as ArrayLength<u8>>::ArrayType: Unpin,
<L as ArrayLength<u8>>::ArrayType: Unpin,
impl<L> UnwindSafe for TcpSocket<L> where
<L as ArrayLength<u8>>::ArrayType: UnwindSafe,
<L as ArrayLength<u8>>::ArrayType: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
[src]
type Output = T
Should always be Self
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,