diff options
| author | Yuval Adam <_@yuv.al> | 2018-07-06 19:20:33 +0300 |
|---|---|---|
| committer | Yuval Adam <_@yuv.al> | 2018-07-06 19:20:33 +0300 |
| commit | 77318de11fd8bc910734ccb79ba4a6a45b4d535f (patch) | |
| tree | bd47351dc1c7a3050aad3f9ee00a4e60f2db9dbe /src/upnp.rs | |
| parent | d0f7dff9a51fa33612b71d03a3736dd107e9a747 (diff) | |
Send out a discovery search request
Diffstat (limited to 'src/upnp.rs')
| -rw-r--r-- | src/upnp.rs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/upnp.rs b/src/upnp.rs new file mode 100644 index 0000000..de67c9c --- /dev/null +++ b/src/upnp.rs @@ -0,0 +1,15 @@ +use std::net::UdpSocket; + +const SEARCH_REQUEST: &'static str = "M-SEARCH * HTTP/1.1\r\n +Host: 239.255.255.250:1900\r\n +Man: \"ssdp:discover\"\r\n +ST: ssdp:all\r\n +MX: 3\r\n +User-Agent: rustcast/0.1.0\r\n\r\n"; + +pub fn discover() { + println!("Discovering..."); + let socket = UdpSocket::bind("[::]:0").unwrap(); + socket.connect("239.255.255.250:1900").unwrap(); + socket.send_to(SEARCH_REQUEST.as_bytes(), "239.255.255.250:1900").expect("couldn't send data"); +} |
