https://github.com/doodzik/plain-tcp
a very simple tcp server and client build with frp-middleware
https://github.com/doodzik/plain-tcp
Last synced: about 1 year ago
JSON representation
a very simple tcp server and client build with frp-middleware
- Host: GitHub
- URL: https://github.com/doodzik/plain-tcp
- Owner: doodzik
- License: gpl-3.0
- Created: 2015-11-16T09:28:58.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2015-11-16T23:04:15.000Z (over 10 years ago)
- Last Synced: 2025-04-23T22:54:33.595Z (about 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 22.5 KB
- Stars: 6
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# plain-tcp
[](https://travis-ci.org/doodzik/plain-tcp)
A very simple tcp server and client build with frp-middleware
Check out the full API over at the [frp-middleware](http://github.com/doodzik/frp-middleware) repo.
# Installation
```bash
$ npm install plain-tcp --save
```
# Usage
```javascript
import assert from 'assert'
import { Server, Client } from 'plain-tcp'
let server = new Server(5442)
server
.map(data => {
assert(data === 'hello')
return 'world'
})
.subscribe()
let client = new Client(5442)
client.emit('hello', data => {
assert(data === 'world')
})
```
# API
### \#emit(String)
Sends a message to the Server. Without handling the response.
### \#emit(String, function)
Sends a message to the Server and calls the provided function with the response.
### \#subscribe()
Starts listening on the port.
If a map returns an empty value the server doesn't respond to the client.