2
0
Fork 1
mirror of https://github.com/async-rs/async-std.git synced 2025-04-08 01:16:41 +00:00
async-std/docs/src/tutorial/specification.md
Florian Gilcher d3c67148b7
Seperate the tutorial in multiple parts
Fix some typos
2019-08-15 15:20:29 +02:00

1.2 KiB

Specification and Getting Started

Specification

The chat uses a simple text protocol over TCP. Protocol consists of utf-8 messages, separated by \n.

The client connects to the server and sends login as a first line. After that, the client can send messages to other clients using the following syntax:

login1, login2, ... login2: message

Each of the specified clients than receives a from login: message message.

A possible session might look like this

On Alice's computer:   |   On Bob's computer:

> alice                |   > bob
> bob: hello               < from alice: hello
                       |   > alice, bob: hi!
                           < from bob: hi!
< from bob: hi!        |

The main challenge for the chat server is keeping track of many concurrent connections. The main challenge for the chat client is managing concurrent outgoing messages, incoming messages and user's typing.

Getting Started

Let's create a new Cargo project:

$ cargo new a-chat
$ cd a-chat

At the moment async-std requires Rust nightly, so let's add a rustup override for convenience:

$ rustup override add nightly
$ rustc --version
rustc 1.38.0-nightly (c4715198b 2019-08-05)