Questions tagged [mio]

MIO is a lightweight IO library for Rust with a focus on adding as little overhead as possible over the OS abstractions.

MIO is a lightweight IO library for Rust with a focus on adding as little overhead as possible over the OS abstractions.

41 questions
0
votes
1 answer

Unable to establish a TLS connection using Rust, Mio and TlsConnector

I'm trying to create a websocket client using tokio_tungstenite and mio but I couldn't initialize a stream because of handshake issues. Here is the code I have: let addr: Vec<_> = ws_url .to_socket_addrs() .map_err(|err| ClientError { …
Adam Starlight
  • 302
  • 3
  • 14
0
votes
0 answers

how to gracefully shutdown websocket clients using tokio

I am implementing a websocket chat application where I want to gracefully shutdown all clients when the server stop because of the ctrl+c signal. I am listening to incoming events using mio poll and tokens. Any new socket connection is registered…
Ashish Singh
  • 739
  • 3
  • 8
  • 21
0
votes
1 answer

Rust + mio tcp client: explicit lifetime required in the type of connection

I want to implement tcp client using mio. This is my code: pub struct Client<'a> { pub connected: bool, connection: Option<&'a TcpStream>, auth_handler: auth::AuthHandler<'a>, } impl Client<'_> { pub fn connect(&mut self, host:…
Sergio Ivanuzzo
  • 1,820
  • 4
  • 29
  • 59
0
votes
0 answers

Rust + mio: got "move occurs value because" when store TcpStream inside struct field

I want to implement TCP client using struct: use std::error::Error; use mio::net::{TcpListener, TcpStream}; use mio::{Events, Interest, Poll, Token}; use std::io::Read; const CLIENT: Token = Token(0); pub struct Client { pub connected: bool, …
Sergio Ivanuzzo
  • 1,820
  • 4
  • 29
  • 59
0
votes
1 answer

Rust ownership issues

I'm quite new to Rust, I'm mainly a C#, javascript and python developer, so I like to approach things in a OOP way, however I still can't wrap my head around ownership in rust. Especially when it comes to OOP. I'm writing a TCP server. I have a…
botiapa
  • 353
  • 2
  • 13
0
votes
0 answers

When does mio make epoll instances?

I want to create a web server that listens to 3 TCP connections and reads data from each one of them. I'm making those connections through a for loop. My understanding is that there would be three different epoll instances, one for each connection.…
pandawithcat
  • 571
  • 2
  • 13
0
votes
0 answers

DCCP support for mio in Rust

I am doing a distributed system project about DCCP protocol. So the aim is for each node to be able to communicate with all other nodes through DCCP protocol. I know I can use a data structure to maintain all sockets that are established. But I want…
Kou Chibin
  • 73
  • 8
0
votes
2 answers

How can I combine discord-rs events with other events from Twitter or timers?

I have written a bot for the Discord chat service using the discord-rs library. This library gives me events when they arise in a single thread in a main loop: fn start() { // ... loop { let event = match connection.recv_event() { …
VP.
  • 15,509
  • 17
  • 91
  • 161
0
votes
0 answers

How can I create a TcpSocket and TcpStream in the same MIO event loop?

Can I create the same server as Server or Client with different sockets? Like A -> B -> C Here, A is a client of server B, B is a server to A but a client of server C. How can I register both of these in the same MIO event_loop?
M Harry
  • 39
  • 3
-2
votes
1 answer

How do I write an async method with Tokio?

I'm trying to write a library that will connect to remote servers and exchange data. I did this in C++ using Boost::Asio and am trying to do the same with Rust. One of the problems I have is mapping concepts from Asio, like async_write/read to…
ruipacheco
  • 15,025
  • 19
  • 82
  • 138
-2
votes
1 answer

Importing mio::tcp::TcpStream but get std::net::tcp::TcpStream

In trying to adapt an example server, not sure what to make of this behaviour where the TcpStream I'm asking for and the one I'm getting appear to be entirely different. Example struct definition: use mio::tcp::TcpStream; struct Connection { …
tadman
  • 208,517
  • 23
  • 234
  • 262
1 2
3