Skip to content

ianic/websocket.zig

Repository files navigation

  • passing all autobahn tests
  • handles per message deflate, including sliding window bits size negotiation
  • uses zlib for message compression/decompression

Include library in you project

There is a minimal project in examples/exe which demonstrates how to use websocket client.

Then you can @import("ws") in src/main.zig. This example uses public echo ws server at ws://ws.vi-server.org/mirror/. Connects to websocket server, sends hello message and prints echoed reply.

Above url is taken from websocat - curl for WebSocket tool.

You can start websocat server locally with for example:

websocat -s 8080

and then connect to it by changing hostname, uri, port to:

    const hostname = "localhost";
    const uri = "ws://localhost/";
    const port = 8080;

References

The WebSocket Protocol RFC
compression extension RFC
autobahn testsuite

mattnite/zig-zlib
zlib

run file tests

zig test src/main.zig --deps zlib=zlib --mod zlib::../zig-zlib/src/main.zig -l z 2>&1 | cat

About

websocket protocol in zig

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published