Skip to content

pull-recvfrom #32

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 16, 2017
Merged

pull-recvfrom #32

merged 1 commit into from
May 16, 2017

Conversation

reqshark
Copy link
Contributor

@reqshark reqshark commented May 9, 2017

pull-recvfrom for doing unix datagrams like IPC on steroids:

  • address format for unix datagrams is a pathname
  • ordered and reliable delivery of udp packets on the same box
  • often orders of magnitude better latency and throughput versus ip stack or tcp
  • communication between applications is limited to the same host machine (osx/linux kernel)

recvfrom in conjunction with sendto gives us a useful advantage over node-unix-dgram, because either the size of user buffers (in the case of sendto) or a number passed to recvfrom automatically reconfigures arbitrarily low max buf size system limits.

one call to kernel's setsockopt() adjusts unix datagram maximums for linux and osx. with sendto you dont have to think about that because we set socket option SO_SNDBUF, raising the send limit size up to the size of whatever node buffer you pass 🍻

yo try that:

var pullfrom = require('pull-recvfrom')
var sockname = '/tmp/ayyyyy'
var pull = require('pull-stream')

pull(
  pullfrom(sockname, require('recvfrom')), // pass address and recvfrom to pullfrom()
  pull.drain(log)
)
function log(buf){
  console.log(buf+'')
}

var sendto = require('sendto')
setInterval(sendto, 500, sockname, Buffer('hello from sendto'))

@ahdinosaur ahdinosaur merged commit 61f7f8f into pull-stream:master May 16, 2017
@ahdinosaur
Copy link
Member

hey this is rad, thanks @reqshark! 💯

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants