Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Add unix socket support? #172

Draft
wants to merge 8 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@ maintenance = { status = "actively-developed" }
all-features = true

[features]
default = ["tcp", "udp", "websocket"] # All features by default
default = ["tcp", "udp", "websocket"] # All features that are crossplatform by default
tcp = ["mio/net", "socket2"]
udp = ["mio/net", "socket2"]
websocket = ["tungstenite", "url", "tcp"]
unixsocket = ["mio/net", "socket2"] # TODO: check if this is really needed

[dependencies]
mio = { version = "0.8", features = ["os-poll"] }
Expand Down
5 changes: 5 additions & 0 deletions examples/throughput/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@
throughput_message_io(Transport::Tcp, CHUNK);
throughput_message_io(Transport::FramedTcp, CHUNK);
throughput_message_io(Transport::Ws, CHUNK);
// for platforms that support it
#[cfg(feature = "unixsocket")]
throughput_message_io(Transport::UnixSocketStream, CHUNK);
#[cfg(feature = "unixsocket")]
throughput_message_io(Transport::UnixSocketDatagram, CHUNK);
println!();
throughput_native_udp(CHUNK);
throughput_native_tcp(CHUNK);
Expand Down Expand Up @@ -234,7 +239,7 @@
let (mut sender, _) = ws_connect(Url::parse(&url_addr).unwrap()).unwrap();
let start_time = Instant::now();
while total_sent < EXPECTED_BYTES {
sender.write_message(Message::Binary(message.clone())).unwrap();

Check warning on line 242 in examples/throughput/main.rs

View workflow job for this annotation

GitHub Actions / Build (i686-unknown-linux-gnu)

use of deprecated method `tungstenite::WebSocket::<Stream>::write_message`: Use `send`
total_sent += message.len();
}
start_time
Expand All @@ -245,7 +250,7 @@
let mut receiver = ws_accept(listener.accept().unwrap().0).unwrap();
let mut total_received = 0;
while total_received < EXPECTED_BYTES {
total_received += receiver.read_message().unwrap().len();

Check warning on line 253 in examples/throughput/main.rs

View workflow job for this annotation

GitHub Actions / Build (i686-unknown-linux-gnu)

use of deprecated method `tungstenite::WebSocket::<Stream>::read_message`: Use `read`
}
let end_time = Instant::now();

Expand Down
4 changes: 3 additions & 1 deletion src/adapters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,7 @@ pub mod framed_tcp;
pub mod udp;
#[cfg(feature = "websocket")]
pub mod ws;
#[cfg(feature = "unixsocket" )]
pub mod unix_socket;
// Add new adapters here
// ...
// ...
Loading
Loading