File: greeter.rs

package info (click to toggle)
websocketd 0.4.1-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 612 kB
  • sloc: makefile: 131; sh: 85; ansic: 78; javascript: 65; cs: 58; perl: 51; python: 43; ruby: 41; php: 40; java: 26; haskell: 20
file content (14 lines) | stat: -rw-r--r-- 359 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
use std::io::{self, Write};

// For each line FOO received on STDIN, respond with "Hello FOO!".
fn main() {
  loop {
    let mut msg = String::new();
    io::stdin()
      .read_line(&mut msg)
      .expect("Failed to read line");
    let msg = msg.trim();
    println!("Hello {}!", msg);
    io::stdout().flush().ok().expect("Could not flush stdout");
  }
}