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

        let sock = new_socket();
        if sock < 0 {
            return Err(Error::last_os_error());
        }
        if unsafe {
            connect(
                sock,
                &vsock_addr as *const _ as *const sockaddr,
                size_of::<sockaddr_vm>() as socklen_t,
            )
        } < 0
        {
            Err(Error::last_os_error())
        } else {
            Ok(unsafe { VsockStream::from_raw_fd(sock) })
        }
    }
/// Open a connection to a remote host.
Open a connection to a remote host.
Open a connection to a remote host .
pub fn connect(addr: &SockAddr) -> Result<Self> {
        let vsock_addr = if let SockAddr::Vsock(addr) = addr {
            addr.0
        } else {
            return Err(Error::new(
                ErrorKind::Other,
                "requires a virtio socket address",
            ));
        };
        let sock = new_socket();
        if sock < 0 {
            return Err(Error::last_os_error());
        }
        if unsafe {
            connect(
                sock,
                &vsock_addr as *const _ as *const sockaddr,
                size_of::<sockaddr_vm>() as socklen_t,
            )
        } < 0
        {
            Err(Error::last_os_error())
        } else {
            Ok(unsafe { VsockStream::from_raw_fd(sock) })
        }
    }
pub fn connect ( addr : & SockAddr ) -> Result < Self > { let vsock_addr = if let SockAddr :: Vsock ( addr ) = addr { addr . 0 } else { return Err ( Error :: new ( ErrorKind :: Other , " " , ) ) ; } ; let sock = new_socket ( ) ; if sock < 0 { return Err ( Error :: last_os_error ( ) ) ; } if unsafe { connect ( sock , & vsock_addr as * const _ as * const sockaddr , size_of :: < sockaddr_vm > ( ) as socklen_t , ) } < 0 { Err ( Error :: last_os_error ( ) ) } else { Ok ( unsafe { VsockStream :: from_raw_fd ( sock ) } ) } }
Open a connection to a remote host.
Open a connection to a remote host .
addr
&SockAddr
addr
&SockAddr