·

能发一个报错信息看看吗

Replies
1

问题应该是解决了 谢谢



    if args_all.len()>1{
        let mut thread_vec : Vec<thread::JoinHandle<()>> = Vec::new();
        for idx in 1..4{
            for idy in 1..255 {
                let thread_join_handle=thread::spawn(move || {
                    let args_all_1:Vec<String> = env::args().collect();
                    let filepath = args_all_1[1].clone(); 
                    let filename = Path::new(&filepath).file_name().unwrap().to_str().unwrap().clone();
                    let ip_format = format!("10.238.{}.{}:2333",idx,idy);
                    println!("{}",ip_format);
                    //runthread
                    if let Ok(mut stream) = TcpStream::connect(ip_format){
                        let mut filename_i = [32;50];
                        let mut filename_get_i = [0;50];
                        filename_i[..filename.len()].copy_from_slice(filename.as_bytes());
                        stream.write(&filename_i).unwrap();
                        stream.read(&mut filename_get_i).unwrap();
                        if filename_get_i==filename_i{
                            let mut sendbuff = [0;2048];
                            let mut f= std::fs::File::open(&filepath).unwrap();
                            let mut n=0;
                            n=f.read(&mut sendbuff).unwrap();
                            while n>0 {
                                if  stream.write(&sendbuff[..n]).unwrap()==n{
                                    n=f.read(&mut sendbuff).unwrap();
                                }else{
                                    break;
                                }
                        }
                    }
                    }
                });
                thread_vec.push(thread_join_handle);   
            }
        }
        let mut joined:i32 = 0;
        for handle in thread_vec{
            if let Ok(_)=handle.join(){
                joined+=1;
                println!("joined:{}",joined);
            }
        }
       
    }