rust tcp server and client 通信

rust tcp server and client 通信

tcpclientuse std::io::Write; use std::net::TcpStream; use std::io; fn main() { // 连接TCP服务器 let mut client = TcpStream::connect("127.0.0.1:9999").expect("连接失败!"); pri...

Rust 2023-03-05 AM 418次 0条
rust 运行参数 读取txt文本内容并显示

rust 运行参数 读取txt文本内容并显示

use std::env; use std::fs; fn main() { let args: Vec<String> = env::args().collect(); println!("{:#?}", args); let filename = &args[1]; println!("在文件 {}&q...

Rust 2023-03-04 AM 392次 0条
rust 提交json格式

rust 提交json格式

use std::collections::HashMap; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { // 请求体 `{"lang":"rust","body":"json&...

Rust 2023-03-03 PM 441次 0条
rust post 提交表单

rust post 提交表单

#[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { // 请求体是`foo=bar&baz=quux` let params = [("id", "88888888"), ("data&quo...

Rust 2023-03-03 PM 387次 0条
rust 循环延时get请求

rust 循环延时get请求

use std::collections::HashMap; use std::thread::sleep; use std::time::Duration; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let three_seconds = Du...

Rust 2023-03-03 PM 441次 0条
rust 循环延时请求api接口解析json 获取ip地址

rust 循环延时请求api接口解析json 获取ip地址

use std::collections::HashMap; use std::thread::sleep; use std::time::Duration; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let three_seconds = Du...

Rust 2023-03-03 PM 557次 0条
rust 延时 windows系统锁屏

rust 延时 windows系统锁屏

use std::process::Command; use std::os::windows::process::CommandExt; use std::thread::sleep; use std::time::Duration; fn main() { let time_seconds = Duration::from_secs(5); sleep(time_...

Rust 2023-03-03 PM 391次 0条
rust 循环延时执行代码

rust 循环延时执行代码

use std::thread::sleep; use std::time::{Duration, Instant}; fn main() { loop { println!("1234"); let three_seconds = Duration::from_secs(3); sleep(three_secon...

Rust 2023-03-03 PM 598次 0条
Rust websocket 客户端实现

Rust websocket 客户端实现

目前rust websocket文档较少,最近为了实现部分工作需要使用rust去做websocket链接网上找了不少,很多没有太多参考价值,websocket 在rust中要保持长连接,期间需要不停的去ping,不然会中断,但是使用线程在常规情况下闭包又无法在循环数据的时候持续的ping,所以引入了一下第三方包。Cargo.toml[dependencies] tokio = { versi...

Rust 2023-03-03 AM 485次 0条
Rust 编写的 HTTP 客户端——reqwest

Rust 编写的 HTTP 客户端——reqwest

前言reqwest 是一个简单而强大的 RUST HTTP 客户端,用于浏览器异步 HTTP 请求。支持 xmlHttpRequest, JSONP, CORS, 和 CommonJS 约束。Reqwest 简单易用,功能强大,包括异步和阻塞模式,可以处理各种类型的请求数据,支持 HTTP 代理、TLS 加密、Cookie 存储等功能,另外还包括了对 WASM 的支持。一、安装与引用在项目的...

Rust 2023-03-03 AM 535次 0条
Rust学习日记

Rust学习日记

StudyRust公众号:《Rust学习日记》Rust 学习日记 源码 ,让你的Rust从0基础小白到大牛https://gitee.com/haoyu3/study-rust/

Rust 2023-03-03 AM 394次 0条