pub struct TcpSocket<const TIMER_HZ: u32, const L: usize> { /* private fields */ }
Expand description

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

Create a socket using the given buffers.

Return the socket handle.

Return the bound endpoint.

Return the connection state, in terms of the TCP state machine.

Set available data.

Get the number of bytes available to ingress.

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

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.

Check whether the receive half of the full-duplex connection buffer is open (see may_recv, and the receive buffer is not full.

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.

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.

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.

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.

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.

Return the amount of octets queued in the receive buffer.

Note that the Berkeley sockets interface does not have an equivalent of this API.

Trait Implementations

Formats the value using the given formatter. Read more
Converts this type into the (usually inferred) input type.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Should always be Self
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.