pub fn sendv(
        &mut self,
        data: &[u8],
        addr: Option<(T::Addr, u16)>,
        snd_info: Option<SndInfo>,
        pr_info: Option<PrInfo>,
        auth_info: Option<AuthInfo>,
        flags: MsgFlags,
    ) -> Result<usize, Errno> {
        let sa = addr.map(|(addr, port)| T::to_sockaddr(addr, port));
        let addrcnt: i32 = if sa.is_some() { 1 } else { 0 };

        let infotype = if auth_info.is_some() || (snd_info.is_some() && pr_info.is_some()) {
            sys::SCTP_SENDV_SPA
        } else if snd_info.is_some() {
            sys::SCTP_SENDV_SNDINFO
        } else if pr_info.is_some() {
            sys::SCTP_SENDV_PRINFO
        } else {
            sys::SCTP_SENDV_NOINFO
        };

        // Build the sctp_sendv_spa structure
        // Even if we don't use full spa, we will use internal fields
        let mut spa_flags: u32 = 0;
        if snd_info.is_some() {
            spa_flags |= sys::SCTP_SEND_SNDINFO_VALID;
        }
        if pr_info.is_some() {
            spa_flags |= sys::SCTP_SEND_PRINFO_VALID;
        }
        if auth_info.is_some() {
            spa_flags |= sys::SCTP_SEND_AUTHINFO_VALID;
        }

        let mut spa = sys::sctp_sendv_spa {
            sendv_flags: spa_flags,
            sendv_sndinfo: snd_info.unwrap_or_default().into_sctp_sndinfo(),
            sendv_prinfo: pr_info.unwrap_or_default().into_sctp_prinfo(),
            sendv_authinfo: auth_info.unwrap_or(sys::sctp_authinfo { auth_keynumber: 0 }),
        };

        let (infoptr, infolen) = match infotype {
            sys::SCTP_SENDV_SPA => (
                &mut spa as *mut sys::sctp_sendv_spa as *mut c_void,
                mem::size_of::<sys::sctp_sendv_spa>(),
            ),
            sys::SCTP_SENDV_SNDINFO => (
                &mut spa.sendv_sndinfo as *mut sys::sctp_sndinfo as *mut c_void,
                mem::size_of::<sys::sctp_sndinfo>(),
            ),
            sys::SCTP_SENDV_PRINFO => (
                &mut spa.sendv_prinfo as *mut sys::sctp_prinfo as *mut c_void,
                mem::size_of::<sys::sctp_prinfo>(),
            ),
            sys::SCTP_SENDV_NOINFO => (ptr::null_mut(), 0),
            _ => unreachable!(),
        };

        let rval = unsafe {
            sys::usrsctp_sendv(
                self.inner,
                data.as_ptr() as *const c_void,
                data.len(), // * mem::size_of<u8>() which is 1
                match sa {
                    Some(mut s) => &mut s as *mut T::Sockaddr as *mut c_void as *mut sys::sockaddr,
                    None => ptr::null_mut(),
                },
                addrcnt,
                infoptr,
                infolen as u32,
                infotype,
                flags.bits() as i32,
            )
        };

        if rval < 0 {
            Err(errno::errno())
        } else {
            Ok(rval as usize)
        }
    }
/// Send data.
///
/// NOTE: usrsctp limits addr to zero or one.  SCTP itself allows
/// multiple addresses.  So we are limited by `usrsctp` on that
/// point.
Send data.
NOTE: usrsctp limits addr to zero or one.  SCTP itself allows
multiple addresses.  So we are limited by `usrsctp` on that
point.
Send data . NOTE : usrsctp limits addr to zero or one . SCTP itself allows multiple addresses . So we are limited by ` usrsctp ` on that point .
pub fn sendv(
        &mut self,
        data: &[u8],
        addr: Option<(T::Addr, u16)>,
        snd_info: Option<SndInfo>,
        pr_info: Option<PrInfo>,
        auth_info: Option<AuthInfo>,
        flags: MsgFlags,
    ) -> Result<usize, Errno> {
        let sa = addr.map(|(addr, port)| T::to_sockaddr(addr, port));
        let addrcnt: i32 = if sa.is_some() { 1 } else { 0 };
        let infotype = if auth_info.is_some() || (snd_info.is_some() && pr_info.is_some()) {
            sys::SCTP_SENDV_SPA
        } else if snd_info.is_some() {
            sys::SCTP_SENDV_SNDINFO
        } else if pr_info.is_some() {
            sys::SCTP_SENDV_PRINFO
        } else {
            sys::SCTP_SENDV_NOINFO
        };
        // Build the sctp_sendv_spa structure
        // Even if we don't use full spa, we will use internal fields
        let mut spa_flags: u32 = 0;
        if snd_info.is_some() {
            spa_flags |= sys::SCTP_SEND_SNDINFO_VALID;
        }
        if pr_info.is_some() {
            spa_flags |= sys::SCTP_SEND_PRINFO_VALID;
        }
        if auth_info.is_some() {
            spa_flags |= sys::SCTP_SEND_AUTHINFO_VALID;
        }
        let mut spa = sys::sctp_sendv_spa {
            sendv_flags: spa_flags,
            sendv_sndinfo: snd_info.unwrap_or_default().into_sctp_sndinfo(),
            sendv_prinfo: pr_info.unwrap_or_default().into_sctp_prinfo(),
            sendv_authinfo: auth_info.unwrap_or(sys::sctp_authinfo { auth_keynumber: 0 }),
        };
        let (infoptr, infolen) = match infotype {
            sys::SCTP_SENDV_SPA => (
                &mut spa as *mut sys::sctp_sendv_spa as *mut c_void,
                mem::size_of::<sys::sctp_sendv_spa>(),
            ),
            sys::SCTP_SENDV_SNDINFO => (
                &mut spa.sendv_sndinfo as *mut sys::sctp_sndinfo as *mut c_void,
                mem::size_of::<sys::sctp_sndinfo>(),
            ),
            sys::SCTP_SENDV_PRINFO => (
                &mut spa.sendv_prinfo as *mut sys::sctp_prinfo as *mut c_void,
                mem::size_of::<sys::sctp_prinfo>(),
            ),
            sys::SCTP_SENDV_NOINFO => (ptr::null_mut(), 0),
            _ => unreachable!(),
        };
        let rval = unsafe {
            sys::usrsctp_sendv(
                self.inner,
                data.as_ptr() as *const c_void,
                data.len(), // * mem::size_of<u8>() which is 1
                match sa {
                    Some(mut s) => &mut s as *mut T::Sockaddr as *mut c_void as *mut sys::sockaddr,
                    None => ptr::null_mut(),
                },
                addrcnt,
                infoptr,
                infolen as u32,
                infotype,
                flags.bits() as i32,
            )
        };
        if rval < 0 {
            Err(errno::errno())
        } else {
            Ok(rval as usize)
        }
    }
pub fn sendv ( & mut self , data : & [ u8 ] , addr : Option < ( T :: Addr , u16 ) > , snd_info : Option < SndInfo > , pr_info : Option < PrInfo > , auth_info : Option < AuthInfo > , flags : MsgFlags , ) -> Result < usize , Errno > { let sa = addr . map ( | ( addr , port ) | T :: to_sockaddr ( addr , port ) ) ; let addrcnt : i32 = if sa . is_some ( ) { 1 } else { 0 } ; let infotype = if auth_info . is_some ( ) || ( snd_info . is_some ( ) && pr_info . is_some ( ) ) { sys :: SCTP_SENDV_SPA } else if snd_info . is_some ( ) { sys :: SCTP_SENDV_SNDINFO } else if pr_info . is_some ( ) { sys :: SCTP_SENDV_PRINFO } else { sys :: SCTP_SENDV_NOINFO } ; // Build the sctp_sendv_spa structure // Even if we don't use full spa, we will use internal fields let mut spa_flags : u32 = 0 ; if snd_info . is_some ( ) { spa_flags |= sys :: SCTP_SEND_SNDINFO_VALID ; } if pr_info . is_some ( ) { spa_flags |= sys :: SCTP_SEND_PRINFO_VALID ; } if auth_info . is_some ( ) { spa_flags |= sys :: SCTP_SEND_AUTHINFO_VALID ; } let mut spa = sys :: sctp_sendv_spa { sendv_flags : spa_flags , sendv_sndinfo : snd_info . unwrap_or_default ( ) . into_sctp_sndinfo ( ) , sendv_prinfo : pr_info . unwrap_or_default ( ) . into_sctp_prinfo ( ) , sendv_authinfo : auth_info . unwrap_or ( sys :: sctp_authinfo { auth_keynumber : 0 } ) , } ; let ( infoptr , infolen ) = match infotype { sys :: SCTP_SENDV_SPA => ( & mut spa as * mut sys :: sctp_sendv_spa as * mut c_void , mem :: size_of :: < sys :: sctp_sendv_spa > ( ) , ) , sys :: SCTP_SENDV_SNDINFO => ( & mut spa . sendv_sndinfo as * mut sys :: sctp_sndinfo as * mut c_void , mem :: size_of :: < sys :: sctp_sndinfo > ( ) , ) , sys :: SCTP_SENDV_PRINFO => ( & mut spa . sendv_prinfo as * mut sys :: sctp_prinfo as * mut c_void , mem :: size_of :: < sys :: sctp_prinfo > ( ) , ) , sys :: SCTP_SENDV_NOINFO => ( ptr :: null_mut ( ) , 0 ) , _ => unreachable ! ( ) , } ; let rval = unsafe { sys :: usrsctp_sendv ( self . inner , data . as_ptr ( ) as * const c_void , data . len ( ) , // * mem::size_of<u8>() which is 1 match sa { Some ( mut s ) => & mut s as * mut T :: Sockaddr as * mut c_void as * mut sys :: sockaddr , None => ptr :: null_mut ( ) , } , addrcnt , infoptr , infolen as u32 , infotype , flags . bits ( ) as i32 , ) } ; if rval < 0 { Err ( errno :: errno ( ) ) } else { Ok ( rval as usize ) } }
Send data.
Send data .
&mut self
data
&[u8]
addr
Option<(T::Addr, u16)>
snd_info
Option<SndInfo>
pr_info
Option<PrInfo>
auth_info
Option<AuthInfo>
flags
MsgFlags
&mut self
data
&[u8]
addr
Option<(T::Addr, u16)>
snd_info
Option<SndInfo>
pr_info
Option<PrInfo>
auth_info
Option<AuthInfo>
flags
MsgFlags