Rust & Zig
This commit is contained in:
parent
ea4ef1d8b3
commit
c2e16f5b83
11 changed files with 226 additions and 15 deletions
7
RustUDSClient/Cargo.lock
generated
Normal file
7
RustUDSClient/Cargo.lock
generated
Normal file
|
@ -0,0 +1,7 @@
|
|||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "RustUDSClient"
|
||||
version = "0.1.0"
|
6
RustUDSClient/Cargo.toml
Normal file
6
RustUDSClient/Cargo.toml
Normal file
|
@ -0,0 +1,6 @@
|
|||
[package]
|
||||
name = "RustUDSClient"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
19
RustUDSClient/src/main.rs
Normal file
19
RustUDSClient/src/main.rs
Normal file
|
@ -0,0 +1,19 @@
|
|||
use std::io::Write;
|
||||
use std::os::unix::net::UnixStream;
|
||||
|
||||
fn main() {
|
||||
let socket = "/tmp/udsserver.sock";
|
||||
let stream_result = UnixStream::connect(socket);
|
||||
match stream_result {
|
||||
Ok(mut stream) => {
|
||||
let message = "Hello, World from RUST™️!";
|
||||
let mut size_buf = [0u8] ;
|
||||
size_buf[0] = message.len() as u8;
|
||||
stream.write(size_buf.as_slice()).unwrap();
|
||||
stream.write_all(message.as_bytes()).unwrap();
|
||||
}
|
||||
Err(e) => {
|
||||
println!("Error: {}", e);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue