pub fn bind(addr: &SockAddr) -> Result<VsockListener> {
        let mut vsock_addr = if let SockAddr::Vsock(addr) = addr {
            addr.0
        } else {
            return Err(Error::new(
                ErrorKind::Other,
                "requires a virtio socket address",
            ));
        };

        let socket = new_socket();
        if socket < 0 {
            return Err(Error::last_os_error());
        }

        let res = unsafe {
            bind(
                socket,
                &mut vsock_addr as *mut _ as *mut sockaddr,
                size_of::<sockaddr_vm>() as socklen_t,
            )
        };
        if res < 0 {
            return Err(Error::last_os_error());
        }

        // rust stdlib uses a 128 connection backlog
        let res = unsafe { listen(socket, 128) };
        if res < 0 {
            return Err(Error::last_os_error());
        }

        Ok(Self { socket })
    }
/// Create a new VsockListener which is bound and listening on the socket address.
Create a new VsockListener which is bound and listening on the socket address.
Create a new VsockListener which is bound and listening on the socket address .
pub fn bind(addr: &SockAddr) -> Result<VsockListener> {
        let mut vsock_addr = if let SockAddr::Vsock(addr) = addr {
            addr.0
        } else {
            return Err(Error::new(
                ErrorKind::Other,
                "requires a virtio socket address",
            ));
        };
        let socket = new_socket();
        if socket < 0 {
            return Err(Error::last_os_error());
        }
        let res = unsafe {
            bind(
                socket,
                &mut vsock_addr as *mut _ as *mut sockaddr,
                size_of::<sockaddr_vm>() as socklen_t,
            )
        };
        if res < 0 {
            return Err(Error::last_os_error());
        }
        // rust stdlib uses a 128 connection backlog
        let res = unsafe { listen(socket, 128) };
        if res < 0 {
            return Err(Error::last_os_error());
        }
        Ok(Self { socket })
    }
pub fn bind ( addr : & SockAddr ) -> Result < VsockListener > { let mut vsock_addr = if let SockAddr :: Vsock ( addr ) = addr { addr . 0 } else { return Err ( Error :: new ( ErrorKind :: Other , " " , ) ) ; } ; let socket = new_socket ( ) ; if socket < 0 { return Err ( Error :: last_os_error ( ) ) ; } let res = unsafe { bind ( socket , & mut vsock_addr as * mut _ as * mut sockaddr , size_of :: < sockaddr_vm > ( ) as socklen_t , ) } ; if res < 0 { return Err ( Error :: last_os_error ( ) ) ; } // rust stdlib uses a 128 connection backlog let res = unsafe { listen ( socket , 128 ) } ; if res < 0 { return Err ( Error :: last_os_error ( ) ) ; } Ok ( Self { socket } ) }
Create a new VsockListener which is bound and listening on the socket address.
Create a new VsockListener which is bound and listening on the socket address .
addr
&SockAddr
addr
&SockAddr