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?