Git Product home page Git Product logo

async-chat's Introduction

Asynchronous chat client and server from Programming Rust

This repository contains the source code for the chat client and server written using the Rust language's asynchronous programming features. It is described in Chapter 20 of the book Programming Rust, by Blandy, Orendorff, and Tindall (ISBN 978-1-492-05259-3).

To run the server, type:

$ cargo run --release --bin server -- localhost:8088

To run the client, type:

$ cargo run --release --bin client -- localhost:8088

The client supports only two commands:

  • join group - Join the group named group. If that group does not exist, it is created. The name of the group must not contain any spaces.

  • post group message - Post message to the chat group named group. The group name must not contain any spaces, but the message can.

There is no command to leave a group. There is no concept of a user name. To exit the client, hit ctrl-D on Linux or macOS, or ctrl-Z on Windows.

An example client session:

$ cargo run --release --bin client -- localhost:8088
    Finished release [optimized] target(s) in 0.04s
     Running `/home/jimb/rust/book/tests/chapters/asynchronous/target/release/client 'localhost:8088'`
Commands:
join GROUP
post GROUP MESSAGE...
Type Control-D (on Unix) or Control-Z (on Windows) to close the connection.
join dogs
post dogs I love dogs!
message posted to dogs: I love dogs!
message posted to dogs: Whaddya know, I do too!
message posted to dogs: Hello, dog lovers!
post dogs Hi!
message posted to dogs: Hi!
ctrl-D
$

async-chat's People

Contributors

jimblandy avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.