1

I built a post processor for creating CNC machine files to which I'd like to provide a web interface.

Currently the program takes a file path as input and then spits out the results into another file. I'd now like to be able to turn the program into a server that receives JSON data.

It's trivial to open a Unix Domain socket with a node.js server, so I thought that would be a good place to start. My plan is to write a server that listens for JSON messages, processes the data and produces the output files for downloading. The communication lines should be two way so the node server can talk to the processing server (error messages and so forth). The communication would be done over Unix Domain sockets.

I'm just not sure on the type of socket, stream or datagram. I expect the JSON messages to be a maximum of about 2 mb. Can a datagram be that big?

Also, what is sent through a Unix socket? Raw bytes or encoded text? The node socket api allows you to set the encoding, but what about the socket() system call?

Socket based IPC is new to me, but it seems like it will provide the functionality I need.

With fairly large messaging requirements, should socket based IPC be done with stream sockets or datagram sockets? Are there any text encoding requirements? Would a stream socket based solution require some sort of custom protocol? Are Unix sockets the best solution for my use case?

  • 1
    It seems that you have made up your mind already about the solution for the problem being unix sockets. I'm curious though, why do you think that's the case? Why not the simpler and well known http server? Which by the way gets along pretty well with JSON. – edalorzo Feb 5 '17 at 23:02
  • The post processor is currently a standalone program. I thought that making it a server that listens to a local socket would be easy to implement. Getting the node server (which is an http server) to communicate with a local socket is easy. Getting the two to communicate with each other should be easy. Maybe I should kjust give it a go and see what happens. – oorst Feb 5 '17 at 23:09

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.