Giter Site home page Giter Site logo

net-websocket-polyfill's Introduction

net-websocket-polyfill

PRs and issues are greatly appreciated

This a browserify polyfill to emulate the net module.

Browserify generates polyfills when it can, but the net module can't be browserified, because browsers don't have access to sockets. This project is meant to emulate the net module by organizing all traffic through WebSockets, instead of Sockets. This module tries to keep the api as similar as possible, but refer to the source code if needed. This means you should be able to plug and play this module instead of the standard net module.

Usage

Load aliasify as a transform. Set this module as an alias for the net module. For example, you could do this in your package.json

  "browserify": {
    "transform": [
      "aliasify"
    ]
  },

Then configure the alias.

"aliasify": {
  "aliases": {
    "net": "net-websocket-polyfill"
  }
},

You need a WebSocket/TCP proxy in order for this to work!. The browser doesn't have access to raw TCP sockets so we should transmit data over a websocket to our proxy. Our proxy will forward data to the specified target. This proxy will work. Then connect to the proxy instead of the target.

TODO:

  • Support IP address and DNS utilities
  • General support
  • Test module with other popular projects

Features

Green checkmarks indicate polyfills that this module has. Features are being added as fast as possible!

Class: net.Socket

  • new net.Socket([options]) ✔️
  • Event: 'close' ✔️
  • Event: 'connect' ✔️
  • Event: 'data' ✔️
  • Event: 'drain'
  • Event: 'end'
  • Event: 'error' ✔️
  • Event: 'lookup'
  • Event: 'ready' ✔️
  • Event: 'timeout'
  • socket.address() ✔️
  • socket.bufferSize ✔️
  • socket.bytesRead
  • socket.bytesWritten
  • socket.connect() ✔️
    • socket.connect(options[, connectListener]) ✔️
    • socket.connect(path[, connectListener]) ✔️
    • socket.connect(port[, host][, connectListener]) ✔️
  • socket.connecting ✔️
  • socket.destroy([exception]) ✔️
  • socket.destroyed ✔️
  • socket.end([data][, encoding][, callback])
  • socket.localAddress
  • socket.localPort
  • socket.pause()
  • socket.pending
  • socket.ref()
  • socket.remoteAddress
  • socket.remoteFamily
  • socket.remotePort ✔️
  • socket.resume()
  • socket.setEncoding([encoding]) ✔️
  • socket.setKeepAlive([enable][, initialDelay])
  • socket.setNoDelay([noDelay])
  • socket.setTimeout(timeout[, callback])
  • socket.unref()
  • socket.write(data[, encoding][, callback]) ✔️

net-websocket-polyfill's People

Contributors

ananthvivekanand avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

net-websocket-polyfill's Issues

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.