socket-exec

connect to a socket, write data, get a promise back

Usage no npm install needed!

<script type="module">
  import socketExec from 'https://cdn.skypack.dev/socket-exec';
</script>

README

socket-exec

Connects to a socket, writes data, returns a Promise which:

  • resolves with any received data when the connection is closed.
  • rejects if there is an error or an optionally defined timeout is reached.

usage

import socketExec from 'socket-exec'

const controlPort = socketExec({ port: 9055 })

controlPort([`AUTHENTICATE\r\n`, `HEARTBEAT\r\n`, `QUIT\r\n`])
  .then(success)
  .catch(error)

api

socketExec(options)

Options are passed on to net.createConnection.