Go to file
Alexey Galakhov 710aa8e6a9 Version 0.5.4 released.
This is a security fix version. Features from the master branch
are scheduled for 0.6.0.

Signed-off-by: Alexey Galakhov <agalakhov@snapview.de>
2018-07-02 18:17:15 +02:00
examples callback static dispatch 2017-10-09 10:36:12 +02:00
src frame: reject frames that are too big for the RAM 2018-07-02 18:16:02 +02:00
.gitignore Initial commit, mostly working client 2017-01-30 10:22:39 +01:00
.travis.yml Add .travis.yml 2017-06-29 16:32:47 +02:00
Cargo.toml Version 0.5.4 released. 2018-07-02 18:17:15 +02:00
LICENSE-APACHE Relicense under MIT + Apache-2.0. 2017-04-11 16:18:09 +02:00
LICENSE-MIT Relicense under MIT + Apache-2.0. 2017-04-11 16:18:09 +02:00
README.md Add use statements to README.md example 2017-08-17 15:12:54 -07:00

README.md

Tungstenite

Lightweight stream-based WebSocket implementation for Rust.

use std::net::TcpListener;
use std::thread::spawn;
use tungstenite::server::accept;

/// A WebSocket echo server
let server = TcpListener::bind("127.0.0.1:9001").unwrap();
for stream in server.incoming() {
    spawn (move || {
        let mut websocket = accept(stream.unwrap(), None).unwrap();
        loop {
            let msg = websocket.read_message().unwrap();

            // We do not want to send back ping/pong messages.
            if msg.is_binary() || msg.is_text() {
                websocket.write_message(msg).unwrap();
            }
        }
    });
}

Take a look at the examples section to see how to write a simple client/server.

MIT licensed Apache-2.0 licensed Crates.io Build Status

Documentation

Introduction

This library provides an implementation of WebSockets, RFC6455. It allows for both synchronous (like TcpStream) and asynchronous usage and is easy to integrate into any third-party event loops including MIO. The API design abstracts away all the internals of the WebSocket protocol but still makes them accessible for those who wants full control over the network.

This library is a work in progress. Feel free to ask questions and send us pull requests.

Why Tungstenite?

It's formerly WS2, the 2nd implementation of WS. WS2 is the chemical formula of tungsten disulfide, the tungstenite mineral.

Features

Tungstenite provides a complete implementation of the WebSocket specification. TLS is supported on all platforms using native-tls.

There is no support for permessage-deflate at the moment. It's planned.

Testing

Tungstenite is thoroughly tested and passes the Autobahn Test Suite for WebSockets. It is also covered by internal unit tests as good as possible.

Contributing

Please report bugs and make feature requests here.