#tcp #server #command #query

linebased

Add a TCP query port to any program

5 unstable releases

0.3.1 Aug 8, 2018
0.3.0 Mar 3, 2017
0.2.1 Jul 25, 2016
0.2.0 Jul 25, 2016
0.1.0 Jul 25, 2016

#42 in HTTP server

Download history 13/week @ 2018-05-16 51/week @ 2018-05-23 31/week @ 2018-05-30 21/week @ 2018-06-13 6/week @ 2018-06-20 60/week @ 2018-06-27 66/week @ 2018-07-04 5/week @ 2018-07-11 15/week @ 2018-07-18 2/week @ 2018-07-25 49/week @ 2018-08-01 29/week @ 2018-08-08

115 downloads per month

MIT/Apache

26KB
561 lines

linebased

Build Status Crates.io

Drop-in TCP command server

About

Simple line-based TCP server for implementing command interfaces. There's no authentication or TLS support. Commands are handled synchronously as in Redis. The server uses an event loop internally to multiplex client connections.

Usage

This example is kept up-to-date on a best-effort basis. For a guaranteed acurate example, please see the docs.

let config = Config::default()
        .host("127.0.0.1")
        .port(5555)
        .max_clients(32)
        .client_buf_size(1024);

let mut server = Server::new(config, |query| {
    match query {
        "version" => String::from("0.1.0"),
        _ => String::from("unknown command"),
    }
}).unwrap();

server.run().unwrap();

This can be accessed over netcat like so:

jwilm@jwilm-desk ➜ nc localhost 5555
arst
unknown command
version
0.1.0

Dependencies

~2.5MB
~42K SLoC