Socket
Socket
Sign inDemoInstall

cross-platform-sock

Package Overview
Dependencies
0
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    cross-platform-sock

Create a unix sockets on both unix and windows


Version published
Weekly downloads
547
decreased by-36.69%
Maintainers
1
Install size
4.47 kB
Created
Weekly downloads
 

Readme

Source

cross-platform-sock

Create unix sockets on both unix systems and windows

npm install cross-platform-sock

build status Build status

On unix it'll just use a unix socket and on windows it'll return a pipe name.

Usage

const xsock = require('cross-platform-sock')
const net = require('net')

const server = net.createServer(function (socket) {
  socket.end('hello unix socket')
})

const sock = xsock('./test.sock')

xsock.unlink(sock, function () {
  server.listen(sock, function () {
    const socket = net.connect(sock)

    socket.on('data', function (data) {
      console.log('data:', data)
    })
  })
})

Running the above should print

data: hello unix socket

On all systems.

API

sock = xsock(name)

Create a cross platform socket name.

xsock.unlink(sock, cb)

Unlink a previous socket. Only needed on unix systems. On windows this is just a noop.

License

MIT

FAQs

Last updated on 06 Mar 2018

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc