Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

chrome-net

Package Overview
Dependencies
Maintainers
1
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

chrome-net

Use the Node `net` API in Chrome Apps

  • 1.2.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.6K
decreased by-73.35%
Maintainers
1
Weekly downloads
 
Created
Source

chrome-net

NPM Version NPM Gittip

Use the Node net API in Chrome Apps

This module lets you use the Node.js net (TCP) API in Chrome Packaged Apps.

Instead of learning the quirks of Chrome's chrome.socket API for networking in Chrome Apps just use the higher-level node API you're familiar with. Then, compile your code with browserify and you're all set!

This module is used by webtorrent.

install

npm install chrome-net

methods

Use node's net API, including all parameter list shorthands and variations.

Example TCP client:

var net = require('chrome-net')

var client = net.createConnection({
  port: 1337,
  host: '127.0.0.1'
})

client.write('beep')

client.on('data', function (data) {
  console.log(data)
})

// .pipe() streaming API works too!

Example TCP server:

var net = require('chrome-net')

var server = net.createServer()

server.on('listening', function () {
  console.log('listening')
})

server.on('connection', function (sock) {
  console.log('Connection from ' + sock.remoteAddress + ':' + sock.remotePort)
  sock.on('data', function (data) {
    console.log(data)
  })
})

server.listen(1337)

See nodejs.org for full API documentation: net

contribute

To run tests, use npm test. The tests will run TCP and UDP servers and launch a few different Chrome Packaged Apps with browserified client code. The tests currently require Chrome Canary on Mac. If you're on Windows or Linux, feel free to send a pull request to fix this limitation.

license

MIT. Copyright (c) Feross Aboukhadijeh & John Hiesey.

Keywords

FAQs

Package last updated on 30 Jan 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc