Struct Socket

Source
pub struct Socket { /* private fields */ }
Expand description

A structure representing an unconnected SCTP Socket.

When we listen on this socket, we get an Listener on which we can accept to get a ConnectedSocket (This is like TCPStream but since this can have multiple associations, we are calling it a ‘connected’ socket).

Implementations§

Source§

impl Socket

Source

pub fn new_v4(assoc: SocketToAssociation) -> Result<Self>

Create a New IPv4 family socket.

SocketToAssociation determines the type of the socket created. For a TCP style socket use OneToOne and for a UDP style socket use OneToMany. The socket created is set to a non-blocking socket and is registered for polling for read-write events. For any potentially blocking I/O operations, whether the socket is ‘readable’ or ‘writable’ is handled internally.

Source

pub fn new_v6(assoc: SocketToAssociation) -> Result<Self>

Create a New IPv6 family socket.

SocketToAssociation determines the type of the socket created. For a TCP style socket use SocketToAssociation::OneToOne and for a UDP style socket use SocketToAssociation::OneToMany. The socket created is set to a non-blocking socket and is registered for polling for read-write events. For any potentially blocking I/O operations, whether the socket is ‘readable’ or ‘writable’ is handled internally.

Source

pub fn bind(&self, addr: SocketAddr) -> Result<()>

Bind a socket to a given IP Address.

The passed IP address can be an IPv4 or an IPv6, IP address. For the IPv6 family sockets, it is possible to bind to both IPv4 and IPv6 addresses. IPv4 family sockets can be bound only to IPv4 addresses only.

Source

pub fn listen(self, backlog: i32) -> Result<Listener>

Listen on a given socket.

This successful operation returns Listener consuming this structure. The backlog parameter determines the length of the listen queue.

Source

pub async fn connect( self, addr: SocketAddr, ) -> Result<(ConnectedSocket, AssociationId)>

Connect to SCTP Server.

The successful operation returns ConnectedSocket consuming this structure.

Source

pub fn sctp_bindx(&self, addrs: &[SocketAddr], flags: BindxFlags) -> Result<()>

SCTP Specific extension for binding to multiple addresses on a given socket. See Section 9.1 RFC 6458.

sctp_bindx API can be used to add or remove additional addresses to an unbound (ie newly created socket) or a socket that is already bound to address(es) (flag Add). It is also possible to ‘remove’ bound addresses from the socket using the same API (flag Remove). See the section 9.1 for more details about the semantics of which addresses are acceptable for addition or removoal using the sctp_bindx API.

Source

pub async fn sctp_connectx( self, addrs: &[SocketAddr], ) -> Result<(ConnectedSocket, AssociationId)>

Connect to a multi-homed Peer. See Section 9.9 RFC 6458

An Unbound socket when connected to a remote end would return a tuple containing a connected socket and an associaton ID. In the case of One-to-many sockets, this association ID can be used for subscribing to SCTP events and requesting additional anciliary control data on the socket.

Source

pub fn sctp_subscribe_event( &self, event: Event, assoc_id: SubscribeEventAssocId, ) -> Result<()>

👎Deprecated since 0.2.2: use sctp_subscribe_events instead.

Subscribe to a given SCTP Event on the given socket. See section 6.2.1 of RFC6458.

SCTP allows receiving notifications about the changes to SCTP associations etc from the user space. For these notification events to be received, this API is used to subsribe for the events while receiving the data on the SCTP Socket.

Source

pub fn sctp_unsubscribe_event( &self, event: Event, assoc_id: SubscribeEventAssocId, ) -> Result<()>

👎Deprecated since 0.2.2: use sctp_unsubscribe_events instead.

Unsubscribe from a given SCTP Event on the given socket. See section 6.2.1 of RFC6458.

See sctp_subscribe_event for further details.

Source

pub fn sctp_subscribe_events( &self, events: &[Event], assoc_id: SubscribeEventAssocId, ) -> Result<()>

Subscribe to SCTP Events. See section 6.2.1 of RFC6458.

SCTP allows receiving notifications about the changes to SCTP associations etc from the user space. For these notification events to be received, this API is used to subsribe for the events while receiving the data on the SCTP Socket.

Source

pub fn sctp_unsubscribe_events( &self, events: &[Event], assoc_id: SubscribeEventAssocId, ) -> Result<()>

Unsubscribe from a given SCTP Event on the given socket. See section 6.2.1 of RFC6458.

See sctp_subscribe_events for further details.

Source

pub fn sctp_setup_init_params( &self, ostreams: u16, istreams: u16, retries: u16, timeout: u16, ) -> Result<()>

Setup parameters for a new association.

To specify custom parameters for a new association this API is used.

Source

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

Request to receive RcvInfo ancillary data.

SCTP allows receiving ancillary data about the curent data received on the given socket. This API is used to obtain receive side additional info when the data is to be received.

Source

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

Request to receive NxtInfo ancillary data.

SCTP allows receiving ancillary data about the curent data received on the given socket. This API is used to obtain information about the next datagram that will be received.

Source

pub fn sctp_get_status(&self, assoc_id: AssociationId) -> Result<ConnStatus>

Get the status of the connection associated with the association ID.

Auto Trait Implementations§

§

impl Freeze for Socket

§

impl !RefUnwindSafe for Socket

§

impl Send for Socket

§

impl Sync for Socket

§

impl Unpin for Socket

§

impl !UnwindSafe for Socket

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 = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.