2 个版本
0.1.1 | 2020 年 3 月 6 日 |
---|---|
0.1.0 | 2020 年 3 月 6 日 |
#25 in #ftp
6KB
52 行
功能
- 通过 TCP 发送和接收文件
安装
- 作为 cargo 依赖使用
[dependencies]
file_transfer = "0.1.0"
用法
- host_main.rs
use file_transfer::FTP;
use std:fs::File;
fn main() {
// creating new FTP obj with the paramaters of ip:port and the file that you want to write from received file
let ftp = FTP::new("127.0.0.1:8080", File::create("example1.txt"));
// Receives file from client
ftp.recv();
}
- client_main.rs
use file_transfer::FTP;
use std::fs::File;
fn main() {
// Creates new FTP object with paramaters of ip and the file you want to send
let ftp = FTP::new("127.0.0.1:8080", File::open("example.txt"));
// Sends File
ftp.send();
}