![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Server to server(s) tcp bridge with automatic reconnection to each server, the sending queue, the lifetime of the tasks for sending
This is a small framework for connecting 2 or more servers to each other by tcp.
The framework has the function of automatic reconnection to each server, the sending queue, the lifetime of the tasks for sending.
With yarn
:
yarn add tcp-bridge
or with npm
:
npm install tcp-bridge
For a simple connection of two servers on localhost, you can do this:
const BridgeClass = require('tcp-bridge');
const Bridge = new BridgeClass();
Bridge.addPoint({
port: 2020
});
Bridge.addPoint({
port: 3030
});
If possible, connections will be established to servers localhost:2020
and localhost:3030
.
All data from server 1 will be sent to server 2. All data from server 2 will be sent to server 1.
Servers may be more
require('tcp-bridge')
returns constructor of Bridge
class.
To create new instance of Bridge
you can do this:
const BridgeClass = require('tcp-bridge');
const Bridge = new BridgeClass();
For debugging you can use debug npm package or with same functionality.
Example debugging:
Install debug
package:
yarn add debug
or:
npm install debug
then code:
const BridgeClass = require('tcp-bridge');
const debug = require('debug');
const Bridge = new BridgeClass(debug);
and run script with debug env variable, ex.:
DEBUG=* node index.js
addPoint(params)
-> point uuid
identifierAdds a new server, initiates a connection and returns a unique identifier.
Signature:
BridgeInstance.addPoint({
port,
host,
reconnectOnClose,
reconnectOnHasSendData,
checkTime,
taskTimeout,
enabledRedirect,
encoding,
})
Parameter | Required | Description | Default value |
---|---|---|---|
port | true | Port of server | |
host | Hostname (or ip) of server | '127.0.0.1' | |
reconnectOnClose | auto reconnect on close connection | true | |
reconnectOnHasSendData | auto reconnect if connection is closed and clinet has data to send | false | |
checkTime | time to check new data for sending | 300 ms | |
taskTimeout | task lifetime (in ms), 0 for disable | 60000 | |
enabledRedirect | if false - data from this point will not be redirected | true | |
encoding | Set the encoding for the socket as a Readable Stream. See readable.setEncoding() for more information. | null |
removePoint(identifier)
Disconnects and removes server by identifier.
Parameter | Required | Description | Default value |
---|---|---|---|
identifier | true | Identifier of point (server) |
sendDataToPoint(identifier, data)
Send data to one point.
Parameter | Required | Description | Default value |
---|---|---|---|
identifier | true | Identifier of point (server) | |
data | true | Bytes (as in net library in socket.send function) |
getPoint(identifier)
-> point instanceGetting one point instance.
Parameter | Required | Description | Default value |
---|---|---|---|
identifier | true | Identifier of point (server) |
enableRedirect()
Data from this point will be redirected.
disableRedirect()
Data from this point will not be redirected.
on('data', callback)
– event, triggered if data will be receivedon('ready')
– event, triggered if connection is activated.connected
– true, if connection to server is activeconst debug = require('debug');
const BridgeClass = require('tcp-bridge');
const Bridge = new BridgeClass(debug);
const firstUid = Bridge.addPoint({
port: 2020,
encoding: 'utf8',
});
Bridge.addPoint({
port: 3030,
reconnectOnClose: false,
reconnectOnHasSendData: true,
encoding: 'utf8',
});
Bridge.addPoint({
port: 4040,
encoding: 'utf8',
});
Bridge.addPoint({
port: 5050,
encoding: 'utf8',
});
Bridge.removePoint(firstUid);
const lastUid = Bridge.addPoint({
port: 6060,
encoding: 'utf8',
});
const point = Bridge.getPoint(lastUid);
point.on('ready', data => {
console.log('READY');
});
point.on('data', data => {
console.log('DATA', data);
});
FAQs
Server to server(s) tcp bridge with automatic reconnection to each server, the sending queue, the lifetime of the tasks for sending
We found that tcp-bridge demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.