1.0.3 • Published 8 years ago

cordova-chrome-net v1.0.3

Weekly downloads
6
License
MIT
Repository
github
Last release
8 years ago

cordova-chrome-net

Use the Node net API in cordova Apps with the chrome-socket plugins

This module lets you use the Node.js net (TCP) API in cordova/ionic mobile apps using cordova-plugin-chrome-apps-sockets-tcp and cordova-plugin-chrome-apps-sockets-tcpserver plugins for cordova.

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!

This module is used by cordova-bitcore.

install

npm install cordova-chrome-net

methods

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

Example TCP client:

var net = require('cordova-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('cordova-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

license

MIT. Copyright (c) Tobias Scheepers, Feross Aboukhadijeh and John Hiesey.