/// Build an endpoint around a pre-configured socket.
Build an endpoint around a pre-configured socket.
Build an endpoint around a pre - configured socket .
pub fn with_socket(
        self,
        socket: std::net::UdpSocket,
    ) -> Result<(Endpoint, Incoming), EndpointError> {
        let addr = socket.local_addr().map_err(EndpointError::Socket)?;
        let socket = UdpSocket::from_std(socket).map_err(EndpointError::Socket)?;
        let rc = EndpointRef::new(
            socket,
            proto::Endpoint::new(Arc::new(self.config), self.server_config.map(Arc::new)),
            addr.is_ipv6(),
        );
        let driver = EndpointDriver(rc.clone());
        tokio::spawn(async {
            if let Err(e) = driver.await {
                error!("I/O error: {}", e);
            }
        });
        Ok((
            Endpoint {
                inner: rc.clone(),
                default_client_config: self.client_config,
            },
            Incoming::new(rc),
        ))
    }
pub fn with_socket ( self , socket : std :: net :: UdpSocket , ) -> Result < ( Endpoint , Incoming ) , EndpointError > { let addr = socket . local_addr ( ) . map_err ( EndpointError :: Socket ) ? ; let socket = UdpSocket :: from_std ( socket ) . map_err ( EndpointError :: Socket ) ? ; let rc = EndpointRef :: new ( socket , proto :: Endpoint :: new ( Arc :: new ( self . config ) , self . server_config . map ( Arc :: new ) ) , addr . is_ipv6 ( ) , ) ; let driver = EndpointDriver ( rc . clone ( ) ) ; tokio :: spawn ( async { if let Err ( e ) = driver . await { error ! ( " " e ) ; } } ) ; Ok ( ( Endpoint { inner : rc . clone ( ) , default_client_config : self . client_config , } , Incoming :: new ( rc ) , ) ) }
Build an endpoint around a pre-configured socket.
Build an endpoint around a pre - configured socket .
self
socket
std::net::UdpSocket