0

I am currently planning a complicated networking project on Windows IoT Enterprise. Basically, I will have a C program keeping alive a special network interface. This C program should receive tasks in some way from other programs on the same host, which will generally be written in all sorts of languages (e.g. node.js). I have never did such cooperation between tasks. Do you have any advice on how a node.js server can pass information to an already running C program, and preferably receive a success code or an error message? It is very important for me that this process is as fast as possible, as this solution will handle multiple thousand requests per second.

  • "*complicated networking project*", obviously use sockets. In Linux, I use a event driven approach using `epoll_*`. My program is able to handle 200,000+ requests/second. – Example person Feb 11 '22 at 09:16
  • Just by your description alone, it isn't clear whether this is supposed to be client/server or peer/peer. Regardless, "advice" aren't answers, and generally *riddled* with opinion. Both of those conditions (not concrete answers, and subjective opinion) make this a poor candidate question for this site. That said, sockets and eventing (epoll, libuv, whatever), and better get busy, as socket programming in C isn't the most intuitive thing, particularly if you're shooting for scalability. – WhozCraig Feb 11 '22 at 09:18
  • @MártonMikó in your project, are you using an event driven approach, or process/thread driven approach (where you create a new thread for each connection)? – Example person Feb 11 '22 at 09:20
  • I would help you a lot if you were on Linux, but sadly I can't, since you are using Windows. But I can basically tell you what to do: You basically listen on a port, and the other program also listens on a port. You send info to that port, that program sends info to yours through your port. – Example person Feb 11 '22 at 09:23
  • @Exampleperson It is event based and should run 24/7. The epoll idea is great, does it have an alternative for window? – Márton Mikó Feb 11 '22 at 09:23
  • @MártonMikó I am very sorry to say that I cannot help about specifics on Windows – Example person Feb 11 '22 at 09:24
  • @MártonMikó see https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-select, it seems similar – Example person Feb 11 '22 at 09:25
  • Wouldn't sockets on local ports be heavy on the network card? All the other processes would also be network-heavy. – Márton Mikó Feb 11 '22 at 09:26
  • @MártonMikó I can't think of any other way. Even if you somehow use Shared Memory, how would you wait for two different things at the same time? (Connections, Shared Memory) – Example person Feb 11 '22 at 09:27
  • @MártonMikó I don't think in-device transmission (loopback) uses the network card. – Example person Feb 11 '22 at 09:28
  • @MártonMikó see https://github.com/piscisaureus/wepoll – Example person Feb 11 '22 at 09:28
  • For an equivalent of epoll for Windows please read [this](https://stackoverflow.com/questions/67082/what-is-the-best-epoll-kqueue-select-equvalient-on-windows). Note that `select` is quite slow on Windows when the number of waiting sockets is quite big (ie. it does not scale). The loopback is faster but not great since it pass through big layers of the OS network subsystem that are quite expensive. Note that UDP-sockets are faster than TCP ones. Additionally, shared-memory should be even faster although synchronizations are expensive and I find it less flexible / lower-level. – Jérôme Richard Feb 12 '22 at 18:11
  • 1
    You might be interested by higher-level libraries like ZeroMQ which [supports C](https://zeromq.org/languages/c/), claims to be very fast and quite flexible (while being quite famous). – Jérôme Richard Feb 12 '22 at 18:13

1 Answers1

0

In one of the comments I was pointed towards zeroMQ, and I am now using it successfully in my application, thank you for the help!