multicast
This commit is contained in:
parent
6c65b78e6c
commit
fa4cfcd7b8
3 changed files with 41 additions and 1 deletions
|
|
@ -4,6 +4,8 @@ use std::net::{ToSocketAddrs, UdpSocket};
|
|||
use std::time::Duration;
|
||||
use std::thread;
|
||||
use std::sync::{Mutex,Arc};
|
||||
use socket2::{Domain, Socket, Type};
|
||||
use std::net::{Ipv4Addr, SocketAddr};
|
||||
mod color;
|
||||
// Constants from the C code
|
||||
const QUEUE_LEN: usize = 1000;
|
||||
|
|
@ -323,7 +325,11 @@ fn main() {
|
|||
let mut frame_counter: u32 = 0;
|
||||
thread::spawn(move || {
|
||||
let bind_address = format!("0.0.0.0:12345");
|
||||
|
||||
let socket = Socket::new(Domain::IPV4, Type::DGRAM, None).unwrap();
|
||||
socket.set_reuse_address(true).unwrap();
|
||||
socket.set_nonblocking(true).unwrap();
|
||||
socket.join_multicast_v4(&Ipv4Addr::new(239, 1, 1, 1), &Ipv4Addr::new(0, 0, 0, 0)).unwrap();
|
||||
socket.bind(&"0.0.0.0:12345".parse::<SocketAddr>().unwrap().into()).unwrap();
|
||||
// Bind the UDP socket to the specified address and port.
|
||||
let socket = match UdpSocket::bind(&bind_address) {
|
||||
Ok(s) => s,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue