Code Monkey home page Code Monkey logo

learning-websockets's Introduction

NB: There have been certain changes after I refactored my code. Go to the old master branch around 6 commits before this to view the old code. The instructions about the actual protocol still holds though.

Learning Websockets

This repository was originally made to learn about websockets. There was no better way than implementing a websocket server from scratch(since the client sided part is almost trivial). So I've implemented a chat server.

Apologies for grammatical and spelling errors.

Requirements

  • python3
  • any webserver, to host index.html
  • a modern web-browser (tested on firefox 46 and chromium 50)
  • Basic idea/experience using apache/http.server and understanding client/server relationships

Usage

  1. Change host in index.html to the IP "A" where your server.py is running.
  2. Start hosting index.html on a web hosting server(IP "B"). You can use apache if you want, or simply do
$ cd directory_where_index.html_is
$ python3 -m http.server 8888
  1. Start server.py
$ python3 server.py
  1. Point as many web-browsers as you want towards the location of your server (the IP address IP "B")

Note: The IP/location of the WebSocket server and the WebHosting server are unrelated. However, in my testing process, I ran them both off the same machine, so both were localhost for me, with different port numbers.

So to re-iterate, the host in your index.html file points to the IP address of the computer where server.py is running and your browser address bar points to the IP address where your web-hosting server is running. To keep it simple, keep both on your own machine and replace both with localhost.

Brief Explanation of the WebSocket Protocol

Refer to the writeup at http://milindl.org/writeups.html

learning-websockets's People

Contributors

milindl avatar santwanav avatar

Watchers

 avatar  avatar  avatar

Forkers

santwanav

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.