fn bind(mut self, addr: Vec<u8>) -> Result<(), libc::c_int> {
        let sockaddr = I::SocketAddress::parse(addr.as_slice()).ok_or(libc::EFAULT)?;
        trace!("bind UDP sockaddr: {:?}", sockaddr);
        if sockaddr.family() != I::SocketAddress::FAMILY {
            return Err(libc::EAFNOSUPPORT);
        }
        if self.get_state().info.state.is_bound() {
            return Err(libc::EALREADY);
        }
        let local_addr = sockaddr.get_specified_addr();
        let local_port = sockaddr.get_specified_port();

        let listener_id = listen_udp(self.ctx.deref_mut(), local_addr, local_port)
            .map_err(IntoErrno::into_errno)?;
        self.get_state_mut().info.state = SocketState::BoundListen { listener_id };
        I::get_collection_mut(self.ctx.dispatcher_mut())
            .listeners
            .insert(&listener_id, self.binding_id);
        Ok(())
    }
/// Handles a [POSIX socket bind request].
///
/// [POSIX socket bind request]: psocket::DatagramSocketRequest::Bind
Handles a [POSIX socket bind request].
Handles a [ POSIX socket bind request ] .
fn bind(mut self, addr: Vec<u8>) -> Result<(), libc::c_int> {
        let sockaddr = I::SocketAddress::parse(addr.as_slice()).ok_or(libc::EFAULT)?;
        trace!("bind UDP sockaddr: {:?}", sockaddr);
        if sockaddr.family() != I::SocketAddress::FAMILY {
            return Err(libc::EAFNOSUPPORT);
        }
        if self.get_state().info.state.is_bound() {
            return Err(libc::EALREADY);
        }
        let local_addr = sockaddr.get_specified_addr();
        let local_port = sockaddr.get_specified_port();
        let listener_id = listen_udp(self.ctx.deref_mut(), local_addr, local_port)
            .map_err(IntoErrno::into_errno)?;
        self.get_state_mut().info.state = SocketState::BoundListen { listener_id };
        I::get_collection_mut(self.ctx.dispatcher_mut())
            .listeners
            .insert(&listener_id, self.binding_id);
        Ok(())
    }
fn bind ( mut self , addr : Vec < u8 > ) -> Result < ( ) , libc :: c_int > { let sockaddr = I :: SocketAddress :: parse ( addr . as_slice ( ) ) . ok_or ( libc :: EFAULT ) ? ; trace ! ( " " sockaddr ) ; if sockaddr . family ( ) != I :: SocketAddress :: FAMILY { return Err ( libc :: EAFNOSUPPORT ) ; } if self . get_state ( ) . info . state . is_bound ( ) { return Err ( libc :: EALREADY ) ; } let local_addr = sockaddr . get_specified_addr ( ) ; let local_port = sockaddr . get_specified_port ( ) ; let listener_id = listen_udp ( self . ctx . deref_mut ( ) , local_addr , local_port ) . map_err ( IntoErrno :: into_errno ) ? ; self . get_state_mut ( ) . info . state = SocketState :: BoundListen { listener_id } ; I :: get_collection_mut ( self . ctx . dispatcher_mut ( ) ) . listeners . insert ( & listener_id , self . binding_id ) ; Ok ( ( ) ) }
Handles a [POSIX socket bind request].
Handles a [ POSIX socket bind request ] .
mut self
addr
Vec<u8>
mut self
addr
Vec<u8>