These are chat archives for rust-lang/rust

12th
Mar 2019
wyhaya
@wyhaya
Mar 12 03:38
大家好,我想知道如何同时接收来自两个端口的请求
```
```
Hello everyone, I want to know how to receive requests from both ports at the same time.
use std::net::TcpListener;

fn main() {
    let listener1 = TcpListener::bind("127.0.0.1:1234").unwrap();
    listener1.incoming().for_each(|_stream| {
        println!("1234");
    });
    let listener2 = TcpListener::bind("127.0.0.1:1235").unwrap();
    listener2.incoming().for_each(|_stream| {
        println!("1235");
    });
}
Incoming is an infinite loop. He blocks the second port.
cradee
@cradee_gitlab
Mar 12 07:13
@wyhaya take a look at tokio-rs and it's examples. with it you can get non-blocking behavior
Zakarum
@omni-viral
Mar 12 07:28
There were std::select, but it is deprectated now
Or was it only for channels
Ash
@ashthespy
Mar 12 12:05
Is there a way to get cargo to output module build times?
I found RUSTFLAGS="-Z time-passes" but am looking more for per module metrics
Ash
@ashthespy
Mar 12 16:36
Is it just me? I can't get any build with cargo working right now.
$ cargo build
    Updating crates.io index
error: failed to fetch `https://github.com/rust-lang/crates.io-index`

Caused by:
  object not found - no match for id (33f9d5fa243cbfa3f7ed67c7c9a2e4ecccd89df1); class=Odb (9); code=NotFound (-3)
Okay, clearing my $CARGO_HOME/registry/index seemed to fix the issue..