Node.js module to relay raw TCP data from one socket to another. Essentially, it should work like the following:
- A server is started on some port
- It waits for two TCP clients to connect
- As soon as it receives two connections, it starts relaying data from the first socket to second one
- Data is relayed until one of the clients disconnects
- NodeJS version >= 6.9.1
- NPM version >= 3.10.8
- Telnet or any other tool that allows you to connect to remote computer over a TCP/IP network
$ npm install https://github.com/sarsjits/tcp-relayer.git
var relay = require('tcp-relayer');
relay.relayServer(portNumber);
-
Use the above module in your Node app as mentioned in the usage. This will create a server listening over the mentioned port.
-
Run the app
-
Now to connect to the running server, we will use telnet.
-
Client 1
-
Server
-
Sending message to the server even no other TCP client is yet connected.
-
Client 1
-
Server
-
As soon as another client connects to the server, buffered messages are sent to the client. The two clients can now communicate via server.
-
Client 2
-
Server
-
If the connection between two TCP clients is already established. The server will drop the new incoming connection.
-
Client 3
-
Server
- Extending to multiple pair of connections
- Standalone app supporting Graphical Interface.
Provide the feedback at sarsjits@gmail.com