Git Product home page Git Product logo

whacksockets's Introduction

WhackSockets

Simple recreation of the WebSocket Protocol in rust.

Reasoning

I work a lot with websockets, majority of the time to connect to live data, sometimes in rust, most often if not Typescript. However, using libraries like tungstenite and ws almost always abstract all the gritty details away from the developer.
I am trying to get my hands dirty with the WebSocket Protocol.

What I've learnt

  1. Bit manipulation

    • Really cool, using the bitAND operator & with bits that are ones lets you essentially sum the binary. e.g:
    let x: u8 = 0b0000_0010;
    let y: u8 = 0b1111_1111;
    
    println!("{}", x & y); // This prints 2 (effectively summing up the binary x);

    There really isn't much to say here it is pretty surface level bit manipulation but this is the first time I'm working with this so it's pretty cool.
    The bit manipulation is used extensively here as content-length is 'hidden' in the right 7-bits of the second byte (thats a mouthful), the Opcode that lets us know between a Closing frame or a Text frame to Ping and Pong is hidden in the right 4-bits of the first byte, even if the frame we're dealing with is the last fragment or not, this being hidden in the left first-bit of the first byte.

  2. Data Frames

    • WebSockets communicate with Data Frames, I like to think of them as essentially one of those puzzle boxes that once you've solved you get access to the content.
  3. TCP

    • Nothing too fancy, just learnt more about the TCP protocol, maybe one day I'll rebuilt TCP from scratch as a side project?

whacksockets's People

Contributors

leeian1011 avatar

Watchers

 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.