You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
Alexey Galakhov c08f2c72ff client: correct port in request 5 years ago
autobahn test: autobahn: correct configuration 6 years ago
examples Fix various clippy warnings 5 years ago
fuzz Edition 2018, formatting, clippy fixes 5 years ago
scripts test: autobahn: correct configuration 6 years ago
src client: correct port in request 5 years ago
tests Run everything through rustfmt 5 years ago
.gitignore Initial commit, mostly working client 8 years ago
.travis.yml travis: add automated autobahn tests 6 years ago
Cargo.toml Update to bytes 0.5 and input_buffer 0.3 5 years ago
LICENSE-APACHE Relicense under MIT + Apache-2.0. 8 years ago
LICENSE-MIT Relicense under MIT + Apache-2.0. 8 years ago
README.md Fix typo in README.md example 5 years ago

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()).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.