We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 28980d6 commit 465c362Copy full SHA for 465c362
src/lib.rs
@@ -54,9 +54,14 @@ impl Drop for UdpListener {
54
}
55
56
impl UdpListener {
57
+ /// Binds the `UdpListener` to the given local address.
58
pub async fn bind(local_addr: SocketAddr) -> io::Result<Self> {
- let (tx, rx) = mpsc::channel(CHANNEL_LEN);
59
let udp_socket = UdpSocket::bind(local_addr).await?;
60
+ Self::from_tokio(udp_socket).await
61
+ }
62
+ /// Creates a `UdpListener` from an existing `tokio::net::UdpSocket`.
63
+ pub async fn from_tokio(udp_socket: UdpSocket) -> io::Result<Self> {
64
+ let (tx, rx) = mpsc::channel(CHANNEL_LEN);
65
let local_addr = udp_socket.local_addr()?;
66
67
let handler = tokio::spawn(async move {
0 commit comments