1. chrome-net
Use the Node `net` API in Chrome Apps
chrome-net
Package: chrome-net
Created by: feross
Last modified: Mon, 13 Jun 2022 06:00:30 GMT
Version: 3.3.4
License: MIT
Downloads: 22,498
Repository: https://github.com/feross/chrome-net

Install

npm install chrome-net
yarn add chrome-net

chrome-net travis npm downloads javascript style guide

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.sockets 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!

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 on Windows or Chrome Canary on Mac. If you're on Linux, feel free to send a pull request to fix this limitation.

license

MIT. Copyright (c) Feross Aboukhadijeh, John Hiesey & Jan Schär.

Dependencies

RELATED POST

10 Must-Know Windows Shortcuts That Will Save You Time

10 Must-Know Windows Shortcuts That Will Save You Time

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Navigating AWS Networking: Essential Hacks for Smooth Operation

Navigating AWS Networking: Essential Hacks for Smooth Operation

Achieving Stunning Visuals with Unity's Global Illumination

Achieving Stunning Visuals with Unity's Global Illumination

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code