Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/feross/chrome-dgram
Use the Node `dgram` API in Chrome Apps
https://github.com/feross/chrome-dgram
chrome-apps chrome-dgram chrome-extension dgram javascript nodejs udp
Last synced: 21 days ago
JSON representation
Use the Node `dgram` API in Chrome Apps
- Host: GitHub
- URL: https://github.com/feross/chrome-dgram
- Owner: feross
- License: mit
- Created: 2013-11-10T01:50:22.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2023-12-07T15:03:23.000Z (11 months ago)
- Last Synced: 2024-09-19T14:38:02.305Z (about 2 months ago)
- Topics: chrome-apps, chrome-dgram, chrome-extension, dgram, javascript, nodejs, udp
- Language: JavaScript
- Homepage: https://webtorrent.io
- Size: 103 KB
- Stars: 39
- Watchers: 6
- Forks: 16
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# chrome-dgram [![travis][travis-image]][travis-url] [![npm][npm-image]][npm-url] [![downloads][downloads-image]][downloads-url] [![javascript style guide][standard-image]][standard-url]
[travis-image]: https://img.shields.io/travis/feross/chrome-dgram/master.svg
[travis-url]: https://travis-ci.org/feross/chrome-dgram
[npm-image]: https://img.shields.io/npm/v/chrome-dgram.svg
[npm-url]: https://npmjs.org/package/chrome-dgram
[downloads-image]: https://img.shields.io/npm/dm/chrome-dgram.svg
[downloads-url]: https://npmjs.org/package/chrome-dgram
[standard-image]: https://img.shields.io/badge/code_style-standard-brightgreen.svg
[standard-url]: https://standardjs.com### Use the Node `dgram` API in Chrome Apps
This module lets you use the Node.js [dgram](http://nodejs.org/api/dgram.html) (UDP) API in [Chrome Packaged Apps](http://developer.chrome.com/apps/about_apps.html).
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](https://github.com/substack/node-browserify) and you're all set!
This module is used by [webtorrent](https://github.com/feross/webtorrent).
## install
```
npm install chrome-dgram
```## methods
Use node's `dgram` API, including all parameter list shorthands and variations.
Example UDP client/bind:
```js
var dgram = require('chrome-dgram')var sock = dgram.createSocket('udp4')
sock.send('beep', 0, 'beep'.length, 1337, '127.0.0.1')
sock.on('message', function (data, rInfo) {
console.log('Got data from ' + rInfo.address + ':' + rInfo.port)
console.log(data)
})
```See nodejs.org for full API documentation: [dgram](http://nodejs.org/api/dgram.html)
## 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](http://feross.org) & John Hiesey.