socket.io-tcp-proxy

0.0.5 • Public • Published

socket.io-tcp-proxy

NPM version

TCP proxy server for socket.io websockets.

Description

Spins up a node server locally on port 8080 by default. Connect to this using socket.io WebSockets to send and receive data to/from a TCP endpoint.

Installation

The easiest way to install socket.io-tcp-proxy is with npm.

npm install -g socket.io-tcp-proxy

Alternately, download the source.

git clone https://github.com/ccroy/socket.io-tcp-proxy.git

Command line interface

Start the program from the cli as sitp. It accepts the following arguments:

  • -port <port number>: Sets the port that the WebSocket will connect to.

Usage

  1. Connect to server from web app.
  2. Create session with remote TCP via server.
  3. Add listener for data and any emitters you want.

Note: data is both sent and received as an ArrayBuffer.

Connecting to server from web app

Example:

let ws = io('http://localhost:8080');

Setting up remote TCP session via server

Example:

ws.emit('create', {ip: '123.456.789.012', port: 1234});

Adding handler for incoming data from TCP endpoint

Example:

ws.on('serverData', arrayBuffer => {
  console.log('Data received');
  // Do something with data
});

Add emitters for sending data to TCP endpoint

Example:

ws.emit('clientData', arraybuffer);

Destroy all existing TCP connections

Example:

ws.emit('destroy');

License

MIT

Package Sidebar

Install

npm i socket.io-tcp-proxy

Weekly Downloads

0

Version

0.0.5

License

MIT

Unpacked Size

13 kB

Total Files

17

Last publish

Collaborators

  • ccroy