| 1 | use std::net::UdpSocket; |
| 2 | use std::sync::{Once, ONCE_INIT}; |
| 3 | |
| 4 | // Start windows socket library - From socket2-rs |
| 5 | pub(crate) fn init_winsock() { |
| 6 | static INIT: Once = ONCE_INIT; |
| 7 | |
| 8 | INIT.call_once(|| { |
| 9 | // Initialize winsock through the standard library by just creating a |
| 10 | // dummy socket. Whether this is successful or not we drop the result as |
| 11 | // libstd will be sure to have initialized winsock. |
| 12 | let _ = UdpSocket::bind("127.0.0.1:34254"); |
| 13 | }); |
| 14 | } |