Address in use for unixdatagram socket


Dear All,

I am trying to do something like this :

extern crate mktemp;
use mktemp::Temp;
use std::path::{Path, PathBuf};

fn main()
     let mut temp_file = Temp::new_file().unwrap();
     let path_buf = temp_file.to_path_buf();
     println!("path_buf {:?}", path_buf);
     let sock = std::os::unix::net::UnixDatagram::bind(temp_file).unwrap();


This panics saying that the address is already in use ?
path_buf "/tmp/25579a9be0844868b77d6ba0c31c1f67"
thread ‘main’ panicked at ‘called Result::unwrap() on an Err value: Error { repr: Os { code: 98, message: “Address
already in use” } }’, /checkout/src/libcore/
note: Run with RUST_BACKTRACE=1 for a backtrace.

Should I need to use socket reuse address here ?


The file must not exist when bind is called. So provide a path to a file but don’t create it (bind will do that).