New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

jsonsocket

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jsonsocket - npm Package Compare versions

Comparing version 0.0.1 to 1.0.0

.jshintrc

13

package.json
{
"name": "jsonsocket",
"version": "0.0.1",
"version": "1.0.0",
"description": "JSON socket",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test": "make test"
},

@@ -23,3 +23,10 @@ "repository": {

},
"homepage": "https://github.com/smmoosavi/jsonsocket"
"homepage": "https://github.com/smmoosavi/jsonsocket",
"dependencies": {
"debug": "^2.1.1"
},
"devDependencies": {
"chai": "^1.10.0",
"mocha": "^2.1.0"
}
}
# jsonsocket
JSON socket
Comming ...
## Install
```
$ npm install jsonsocket
```
## Usage
```js
var JsonSocket = require('jsonsocket');
```
## Methods
### `JsonSocket(ip, port)`
Create new json socket from ip and port.
```js
var socket = new JsonSocket('127.0.0.1', 7000);
```
### `JsonSocket(socket)`
Create new json socket from existing`net.Socket`
```js
var net = require('net');
var server = net.createServer(function (con) {
var socket = new JsonSocket(con);
}
```
### `write(data)`
Send object over socket.
```js
socket.write({foo: 'bar'});
```
### `disconnect()`
Destroy connection
### `on(eventType, listener)`
Inherited from `events.EventEmitter`
## Events
### connect
Emitted when socket connected (only when you pass ip, port).
### json
Emitted when full json received.
```js
socket.on('json', function (json) {
console.log(json);
}
```
### disconnect
Emitted when disconnected.
## Logging
You can enable logging. [See more](https://github.com/visionmedia/debug)
```bash
# disabled logging
node test.js
# connect, disconnect log
DEBUG=JsonSocket:connection node test.js
# data log
DEBUG=JsonSocket:data node test.js
# all json socket logs
DEBUG=JsonSocket:* node test.js
```
## Protocol
We send json objects over socket then write one `\0`. This is c/c++ friendly protocol. :smile:
```
{"x": 3}\0null\0"Hi"\0[]\0
```

Sorry, the diff of this file is not supported yet

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